通过Teamcity使用msbuild部署Web项目时出错(msdeploypublish)

时间:2013-11-26 14:53:27

标签: msbuild teamcity msdeploy webdeploy

我在Teamcity的构建配置中的vsproject上有这个标准的msbuild部署方法

/P:DeployIisAppPath=%env.IISSiteName%
/P:Configuration=%env.configuration%
/P:DeployOnBuild=True
/P:DeployTarget=MSDeployPublish
/P:MsDeployServiceUrl=https://%env.TargetServer%/MsDeploy.axd
/P:AllowUntrustedCertificate=True
/P:MSDeployPublishMethod=Wmsvc
/P:CreatePackageOnPublish=True
/P:UserName=%env.domainUser%
/P:Password=%env.domainPassword%

当目标服务器有点忙(由另一个进程错误使用)时,这种情况会失败:

[VSMSDeploy] C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web\Microsoft.Web.Publishing.targets(4377, 5): Web deployment task failed. ((26.11.2013 11:55:54) An error occurred when the request was processed on the remote computer.)

(26.11.2013 11:55:54) An error occurred when the request was processed on the remote computer.
An error was encountered when processing operation 'Create File' on 'PersonInfo.ascx'.
The error code was 0x80070020.
The process cannot access 'C:\*****\PersonInfo.ascx' because it is being used by another process.

当我在“办公时间”(0800-1600)部署时,此错误更频繁。

我能做些什么来确保此部署不会失败?

1 个答案:

答案 0 :(得分:1)

当我在过去碰到这个时,这是因为IIS锁定了文件并且此时无法覆盖。您可以采用两种方式,在部署之前发布app_offline.htm文件。这应该会导致整个app域被卸载。或者,停止应用程序池,部署应用程序,然后再次启动它。

至于如何从TeamCity这样做,这可能有点棘手。但是,如果您可以使用msdeploy.exe,则可以使用该命令发布带有simple command的app_offline.htm。或者,如果您想让应用程序池脱机,recycleApp provider应该可以正常工作。

相关问题