[英]Azure DevOps Pipeline to non-Azure site via FTP App_Offline
如果沒有 App_Offline,您將無法覆蓋活動站點的 .dll 位,我也無法刪除它們,因此我肯定需要使站點脫機。 我不想手動執行此操作,因為它會降低管道的用處。
我不能是唯一/第一個需要這樣做的人 - 有沒有人有一些 YAML 可以完成這項特定工作?
您可以按照此處的說明使用“EnableMSDeployAppOffline”功能在部署之前將您的應用程序設置為離線: Web 發布應用程序離線更新和使用校驗和。
如果它不起作用,您還可以添加一個PowerShell 任務來運行腳本,如下所示停止應用程序,部署然后重新啟動應用程序:
param($websiteName, $packOutput)
$website = Get-AzureWebsite -Name $websiteName
# get the scm url to use with MSDeploy. By default this will be the second in the array
$msdeployurl = $website.EnabledHostNames[1]
$publishProperties = @{'WebPublishMethod'='MSDeploy';
'MSDeployServiceUrl'=$msdeployurl;
'DeployIisAppPath'=$website.Name;
'Username'=$website.PublishingUsername;
'Password'=$website.PublishingPassword}
Write-Output "Stopping web app..."
Stop-AzureWebsite -Name $websiteName
Write-Output "Publishing web app..."
$publishScript = "${env:ProgramFiles(x86)}\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\Publish\Scripts\default-publish.ps1"
. $publishScript -publishProperties $publishProperties -packOutput $packOutput
Write-Output "Starting web app..."
Start-AzureWebsite -Name $websiteName
有關詳細信息,請參閱線程: VSTS - 在部署之前使應用程序脫機。
我讓上傳工作...
第 1 步:將 App_Offline.htm 文件添加到 repo
第 2 步:添加一個初始 FTP 步驟以在站點本身的 ftp 上傳之前使站點脫機。 像這樣(設置與實際部署ftp使用的設置類似,除了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'
這使得上傳工作,但使遠程站點脫機(因為那里的根目錄中有一個 app_offline.htm)。
第三步:刪除 app_offline.htm 注意 FTP 任務有一個“customCmds”參數,MS 描述為:
可選 FTP連接后將發送到遠程 FTP 服務器的命令
我的斜體。 自定義命令在定義它們的 FTP 任務之前運行,而不是之后。 因此,我需要另外一個 FTP 上傳任務,這是良性的,但最后一個命令是DELE /web/content/app_offline.htm
。 請注意,需要完整路徑,大概是因為它在設置 remoteDirectory 之前運行。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.