通过Teamcity(msdeploypublish)部署带有msbuild的web项目时出错

通过Teamcity(msdeploypublish)部署带有msbuild的web项目时出错,msbuild,teamcity,msdeploy,webdeploy,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:AllowUntruste

我在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%
当目标服务器有点忙(被另一个进程错误使用)时,此操作偶尔会失败:

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


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

当我过去遇到此问题时,这是因为IIS对该文件有一个锁,此时无法覆盖它。有两种方法,您可以在部署之前发布app_offline.htm文件。这将导致卸载整个应用程序域。或者,停止应用程序池,部署应用程序,然后再次启动它

至于如何从TeamCity做到这一点,这可能有点棘手。但是,如果您可以使用msdeploy.exe,则可以使用该命令发布带有。或者,如果您想使应用程序池脱机,则应该可以使用

[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.