Our Thinking

TFS and Continuous Deployment Part 2: Preparing the Project

Posted by Brad Newman on Oct 1, 2012 3:43:01 PM

This is the second part of a four-part series on using Team Foundation Server and Team Build to set up a continuous deployment environment.

  • Part One: Getting the Lay of the Land
  • Part Two: Preparing the Project for Continuous Deploy
  • Part Three: Creating the Team Build for Continuous Deploy
  • Part Four: Performing Parameterized Deployments with Web Deploy

In this post, we walk through setting up the web project so that all the pieces are in place for enabling the build to deploy the end product.

Environment Configurations

Environment ConfigurationsThe first step in setting up for continuous integration is to set up a solution configuration that matches the environment which we will be continuously deploying.

Select Build -> Configuration Manager from the Visual Studio menu and then select New from the Active Solution Configuration drop down.

Enter a name that matches the deploy environment.  We typically use “Dev” as the development integration environment name.

Configuration Transformations

The principal reason for creating solution configurations is to enable Configuration Transformations.  This is the new MSBuild pipeline method for separating out environment specific configurations and having them “injected” into the configurations that get copied during the package and deploy process.  In-depth information can be found here: http://msdn.microsoft.com/en-us/library/dd465326.aspx.

Right-click the Web.config in the project and select “Add config transforms.” A new file will be added for each configuration found in the project. The new files will be displayed in the Solution Explorer nested underneath the Web.config file and named after the project configuration (i.e. Web.dev.config). Add environment specific configuration values (i.e. Connection string server names, WCF endpoints, etc.) to the new file following the tags in the XDT namespace.

In the following example the connection string found in the original web.config named “ApplicationServices” will be replaced by the value in the connectionString property.

Configuration Transformation Example

 Next Up

Now that the project is all configured to allow different settings for different environments, we will turn our attention to setting up the Team Build in TFS in the next post.

Topics: Application Lifecycle Management (ALM), Microsoft

Our Thinking - The Online Blog is a source for insights, resources, best practices, and other useful content from our multi-disciplinary team of Onliners.

Subscribe to Blog Updates