Azure Web App:发布前删除所有文件

2023-12-31

使用以下 Powershell 脚本发布到 Azure Web App 时,我们经常会遇到问题,即先前发布的文件会导致运行时错误。

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

如何在发布之前删除所有现有文件?

请注意,我们不能使用插槽,因为这需要标准实例,这对于我们的 CI 环境来说太昂贵了。


尝试添加:

'SkipExtraFilesOnServer'=$false;

to your $publishProperties这应该禁用 MSDeploy 用于保留额外文件的 DoNotDeleteRule。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Azure Web App:发布前删除所有文件 的相关文章

随机推荐