We have a powershell script that uses MSDeploy to publish to an azure web app. Currently the build is failing with the following error :
[error]Error Code: ERROR_CONNECTION_TERMINATED
More Information: Web Deploy experienced a connection problem with the server and had to terminate the connection. Contact your server administrator if the problem persists. Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_CONNECTION_TERMINATED.
Error: Unexpected end of file has occurred. The following elements are not closed: results. Line 1, position 11278.
Error count: 1.
The script has retry logic, which kicks in on this failure, so the deploy itself actually completes fine. I think I just need to maybe not throw the error, and allow the retry to do its stuff. Here is the script :
$DeployComplete = $false
$AttemptCount = 1
Write-Output "Deploying Files"
while((!$DeployComplete) -and ($AttemptCount -lt 6)){
try{
$DeployArgs = "-verb:sync -source:contentPath=""$DeploymentPackageLocation"" -dest:contentPath=d:\home\site\wwwroot\,publishSettings=""$publishProfilePath"""
$msdeployEC = (Start-Process -FilePath "C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" -ArgumentList $DeployArgs -Wait -Passthru -NoNewWindow -ErrorAction SilentlyContinue).ExitCode
if($msdeployEC -ne 0){throw}
Remove-Item -Path $publishProfilePath -Force -ErrorAction SilentlyContinue
$DeployComplete = $true
}
catch{
Write-Output "`tDeloyment did not complete successfully. Attempt : $AttemptCount"
$AttemptCount = $AttemptCount + 1
$ErrorMessage = $_.Exception.Message
Write-Output $ErrorMessage
Start-Sleep -Seconds 2
}
}
Could I perhaps just remove the try-catch?