• Tweaking MSDeploy arguments to keep existing files in folder during deployment to IIS

    by  • January 31, 2012 • .net, tfs, visual studio • 2 Comments

    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

    About

    .NET developer at thetrainline.com, previously web developer at MRM Meteorite. Awarded a PhD in misbehaviour detection in wireless ad-hoc networks.A keen C# ASP.net developer bridging the gap with APIs and JavaScript frameworks, one web app at a time.

    http://www.paulkiddie.com

    2 Responses to Tweaking MSDeploy arguments to keep existing files in folder during deployment to IIS

    1. August 9, 2012 at 9:39 pm

      Thanks! This helped me to resolve an intermittent bug we were seeing when deploying web applications using MSDeploy. I’ve blogged about it here: http://www.msigman.com/2012/08/intermittent-error-msdeploy-tfs-directory-empty/

    2. September 30, 2012 at 5:31 pm

      thanks – lifesaver. been struggling with this myself.

    Leave a Reply

    Your email address will not be published. Required fields are marked *