Tweaking MSDeploy arguments to keep existing files in folder during deployment to IIS
January 31, 2012
I recently got into MSDeploy in order to automate the deployment of web application packages to IIS. A great resource that got me most of the way was Web Deployment Painkillers: Microsoft Visual Studio 2010 & MS Deploy, very useful in getting me started via TFS 2010/VS 2010.
What this gave me was the following MSBuild arguments that I put in Process -> Advanced -> MSBuild Arguments, within a TFS build definition I had set up:
/p:DeployOnBuild=True /p:DeployTarget=MsDeployPublish /p:Configuration="Staging" /p:CreatePackageOnPublish=True /p:MsDeployServiceUrl=https://_<server name>_:8172/msdeploy.axd /p:AllowUntrustedCertificate=True /p:username="_<user name>_" /p:password="_<password>_" /p:MSDeployPublishMethod=WMSVC /p:SkipExtraFilesOnServer=True
I was looking for a way to emulate the option you get when you import an application package in IIS (with the web deploy extension installed), which lets you chose whether you want to overwrite existing files in the destination, or not, as I wanted.
Unfortunately, the documentation for MSDeploy seems a little thin on the ground, but it seems argument I was lacking was /p:SkipExtraFilesOnServer=True
. Adding this to the end of the above MSBuild arguments gave me the required behaviour, resulting in the following MSBuild arguments:
/p:DeployOnBuild=True /p:DeployTarget=MsDeployPublish /p:Configuration="Staging" /p:CreatePackageOnPublish=True /p:MsDeployServiceUrl=https://_<server name>_:8172/msdeploy.axd /p:AllowUntrustedCertificate=True /p:username="_<user name>_" /p:password="_<password>_" /p:MSDeployPublishMethod=WMSVC /p:SkipExtraFilesOnServer=True