Visual Studio 2010: Multiple web.config versions

Visual Studio 2010 has support for multiple web.config files. It is one feature of new web application packaging and deployment system. We can create now separate web.config files for each configuration we have for application.

Multiple web.config filesWhen web application is created then it has two configurations: Debug and Release. Visual Studio 2010 creates also two versions of web.config file as is seen on the image. Depending on active configuration correct web.config will be selected. This technique is called web.config transformation and it allows very powerful transformations of configuration files.

We can easily add new configurations and add web.config files for them right through Visual Studio 2010 IDE.

Web.config file is like template for configurations. Also you can handle it as default configuration. Configuration specific configuration files may add settings or change current ones. This is done using simple transformation tags.

Visual Studio 2010 also allows generation of web.config versions using command-line and MSBuild.

Visual Web Developer Team Blog has very good posting about web.config transformation. This posting is titled as Web Deployment: Web.Config Transformation and it gives you complete overview about transformations and packaging of web.config files.

If you want to try these things out on hosting environment then take a look at my blog entry Free ASP.NET 4.0 beta hosting available and Visual Web Developer Team Blog entry Free Web Hosting to try ASP.NET 4 Beta1, VS 2010 Beta1 and MS Web Deployment Tool RC1.

Gunnar Peipman

Gunnar Peipman is ASP.NET, Azure and SharePoint fan, Estonian Microsoft user group leader, blogger, conference speaker, teacher, and tech maniac. Since 2008 he is Microsoft MVP specialized on ASP.NET.

    3 thoughts on “Visual Studio 2010: Multiple web.config versions

    • February 10, 2010 at 11:00 am
      Permalink

      Hey Gunnar. Just installede the RC of VC2010. I had a hardtime finding the multiple .config files. Untill i realised it was only avaliable on web applications. Is this right, that there is no config tranformations for normal Windows Forms projects and other project types?

      Thanks

    • February 10, 2010 at 12:18 pm
      Permalink

      Hi Joe!

      AFAIK multiple config versions are only in web application projects available.

    • Pingback:Visual Studio 2010: Web.config transforms | Gunnar Peipman - Programming Blog

    Leave a Reply

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