Azure Web App: Delete all files before publish

社会主义新天地 提交于 2019-12-21 20:28:44

问题


When publishing to our Azure Web App using the following Powershell script, we often have issues whereby files from the previous publish cause runtime errors.

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"

Write-Output "Starting web app..."
Start-AzureWebsite -Name $websiteName

. $publishScript -publishProperties $publishProperties  -packOutput $packOutput

How can I delete all the existing files before the publish?

Note that we cannot use slots because this requires Standard instances, which are too expensive for our CI environment.


回答1:


try adding:

'SkipExtraFilesOnServer'=$false;

to your $publishProperties that should disable the DoNotDeleteRule MSDeploy uses to keep extra files around.



来源:https://stackoverflow.com/questions/32623397/azure-web-app-delete-all-files-before-publish

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!