Error when deploying web project with msbuild via Teamcity (msdeploypublish)

1

I have this standard msbuild deployment method on a vsproject in a build config in Teamcity

/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%

This occationally fails when the destination server is a bit busy (used by another process error):

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

When I deploy in "office-hours" (0800-1600) this error is more frequently.

Is there anything I can do to ensure that this deployment will not fail?

msbuild
teamcity
msdeploy
webdeploy
asked on Stack Overflow Nov 26, 2013 by Martin

1 Answer

1

When I've run into this in the past, it's because IIS has a lock on the file and it can't be overwritten at that moment. Two ways you can go, you can publish an app_offline.htm file right before the deploy. That should cause the entire app domain to be unloaded. Or, stop the app pool, deploy the application then start it again.

As for how to do it from TeamCity, that maybe a little tricky. But if you can use msdeploy.exe you can use the command to publish a app_offline.htm with a simple command. Or if you want to take the app pool offline, the recycleApp provider should work.

answered on Stack Overflow Dec 4, 2013 by Steven V

User contributions licensed under CC BY-SA 3.0