Wednesday, September 7, 2011

Automatic deploy multiple websites in a solution using TFS Continious build

On the internet are a lot of resources to be found to automatically deploy websites to your (development) webserver. Here's how I solved that problem:

First of all, make sure your Team Foundation Server Continious build is up and running, and building packages the way you configured is.
Second of all, make sure you can deploy your website using the single click publish using MsDeploy.
Now edit the project file of the project(s) you would like to deploy and add the following tags in the PropertyGroup element:
<DeployTarget>MsDeployPublish</DeployTarget>
<CreatePackageOnPublish>false</CreatePackageOnPublish>
<MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
<MSDeployServiceUrl>https://yourwebserver:8172/MsDeploy.axd</MSDeployServiceUrl>
<UserName>YOURDOMAIN\User</UserName>
<Password>yourpassword</Password>
<AllowUntrustedCertificate>true</AllowUntrustedCertificate>
In the PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " element add the application path. By doing this, we can deploy different configuration types to app paths. If you need for example also a different username and password, you can add them in this section too.
<DeployIisAppPath>websites/Website</DeployIisAppPath>
Once we've edited the projects as mentioned above, we can setup the Build:

Voila! You're finished! Now build and watch your site change!

Save the build configuration and start a new build. If everything is correct, the website will be deployed on each build! For references you can look at the site of Vishal Joshi:
http://vishaljoshi.blogspot.com/2010/11/team-build-web-deployment-web-deploy-vs.html
http://vishaljoshi.blogspot.com/2009/11/web-deployment-painkillers-vs-2010-ms.html

and stack overflow:
http://stackoverflow.com/questions/2878385/how-do-you-deploy-a-website-and-database-project-using-tfs-2010

1 comment:

  1. Note to self to preserve the files on the server: true
    as found in http://stackoverflow.com/a/2656714/288170

    ReplyDelete