Thursday, 16 May 2013

Continuous Integration - TFS Build web deploy

I have been working on web development for a while no wand using TFS 2010 and 2012.
For a while I am using "web deployment" functionality.

In this article I make the assumption that:
  1. You know how to setup TFS build.
  2. You have setup MS Deploy on your IIS application.
  3. Your are using IIS 7 or higher

To create next step in CI is to have build server deploy your latest version of code to the website.

I am using default build template for this deployment.

Make sure that Web deploy is installed on the server (TFS and deployment)
Note: I am using version Web Deploy 3.0




From the picture you can see default build configuration.

I am using MSBuild arguments in order to realize my deployment.

Now the arguments you need to provide to be able to create deployment.
 
/p:DeployOnBuild=True /p:DeployTarget=MsDeployPublish /p:MSDeployPublishMethod=InProc /p:CreatePackageOnPublish=True /p:MSDeployServiceUrl=localhost /p:DeployIisAppPath="Your Project App Name" /p:UserName=domain\user /p:Password=userPassword

I have had few attempts to do this right, but the most important issue I have had is:
  1. Too long output drop folder in build configuration ( file path exceeded 248 characters)
  2. Insufficient write permissions. This was due to account that is running build did not had write access to folder. Do not let it fool you, account that does the publishing has to have access rights to write into the folder.  Alternative is web deploy service has to run under account that has write privilege to write into target folder.