Azure Web App:发布前删除所有文件 [英] Azure Web App: Delete all files before publish

查看:16
本文介绍了Azure Web App:发布前删除所有文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.0Common7IDEExtensionsMicrosoftWeb ToolsPublishScriptsdefault-publish.ps1"

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

. $publishScript -publishProperties $publishProperties  -packOutput $packOutput

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

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

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

推荐答案

尝试添加:

'SkipExtraFilesOnServer'=$false;

到您的 $publishProperties 应该禁用 DoNotDeleteRule MSDeploy 用于保留额外文件.

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

这篇关于Azure Web App:发布前删除所有文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆