I got the upload to work...
Step 1: Add an App_Offline.htm file to the repo
Step 2: add an initial FTP step to take the site offline before the ftp upload of the site itself. Like this (settings are similar to those used for the actual deployment ftp, except for the filePatterns):
- task: FtpUpload@2
inputs:
credentialsOption: 'inputs'
serverUrl: 'ftp://ftpx.ftptothesite.com' # 3rd party hoster site address
username: '$(ftpUsername)'
password: '$(ftpPassword)'
rootDirectory: '$(Build.ArtifactStagingDirectory)/s'
filePatterns: 'app_offline.htm'
remoteDirectory: '/web/content/'
preservePaths: true
trustSSL: true
displayName: 'Take site offline'
That makes the upload work, but leaves the remote site offline (because there's an app_offline.htm in the root there).
Step3: Delete app_offline.htm
Note that the FTP task has a "customCmds" parameter which MS describe as:
Optional FTP Commands that will be sent to the remote FTP
server upon connection
My italics. The custom commands are run before the FTP task they are defined in, not after. Hence I needed one more FTP upload task, of something benign, but with a DELE /web/content/app_offline.htm
as the last command. Note that the full path is needed, presumably as this runs before the remoteDirectory is set up.