gpt4 book ai didi

powershell - Azure Web应用程序: Delete all files before publish

转载 作者:行者123 更新时间:2023-12-04 01:36:11 24 4
gpt4 key购买 nike

使用以下 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;

到您的 $publishProperties ,该属性应禁用 MSDeploy 用于保留额外文件的 DoNotDeleteRule。

关于powershell - Azure Web应用程序: Delete all files before publish,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32623397/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com