Managing configuration settings for different environments with config transformations

When you create a new web application in Visual Studio 2010, you will by default get a configuration file like this:

Web.config transformations

The web.config transformations allow you to adapt your configuration settings for different builds or environments. We have all worked with development, test and production environments where our settings differ from each other like:

  • Database connection strings
  • Endpoints
  • Credentials
  • Domains
  • Application settings
  • Debug mode
  • Tracing
  • Folders or shares
  • ….

When working with different environments, you are bound to be working with different configuration settings. Web transformations allows us to transform our configuration file to the correct configuration file for the environment we want to publish to. By default we get a Debug and Release transformation file. We want to add a tranformation file for developent, test and production environment.

1. How to use web.config transformations to manage your different configurations

For demo purposes we will take a simple web.config file which looks like the following:

Using web.config transformations to manage configuration for different environments

This is the web.config file which is containing our development settings. We will start by changing our configurations by the Configuration Manager:

Continue reading