How Do I: Web.Config Transformations in VS2010

Posted on April 8, 2010 by

This entry is part 1 of 5 in the series How Do I?

This is my first in a series of videos related to Visual Studio 2010 in the “How Do I” format. The videos themselves are short snippets that help you understand how to do specific things within the Visual Studio 2010 IDE. This first one is about web.config transformations.

In the past, dealing with environment-specific data points like Connection Strings, Logging Settings, etc. has been a real challenge. Most organizations have invented their own slick way to manage these different settings from environment to environment, but until now there hasn’t been a comprehensive, prescribed best practice for dealing with this challenge. Now, with Visual Studio 2010, a new feature called Web.Config Transformations solves this complex problem for you! Using the power of XSLT and some integrated tooling, you can now maintain separate settings for individual configuration items across an infinite number of configurations. Check out the video below for more details.

To see all the videos in this series, check out my channel on Vimeo

Series NavigationHow Do I: Code Navigation Improvements in VS2010
  • http://www.robusthaven.com/articles/MSBuild+FlexibleConfigTask Leblanc Meneses

    Hi Chris,

    I have a MSBUILD task http://www.robusthaven.com/articles/MSBuild+Fle…

    which allows a developer to create a config or any file that needs to be conditionally evaluated using C# syntax. I have an example at the very bottom that conditionally evaluates (creates) an xslt merge file that merge Elmah into an existing web.config with AltovaXML.

  • Peter Karaganis

    This is awesome, and a feature that has been needed for a loooooong time. The only issue I'm having, is that if I upgrade a vs2008 application, the config file doesn't have the drill down to the various build configuration versions. Any thoughts?

    • http://chriskoenig.net Chris Koenig

      Thank you for your email. I am attending and presenting at an internal Microsoft conference today, so my access to email wil be delayed. Feel free to call me at 214-385-5616 if you need to reach me quickly, otherwise I will get back to you as soon as I can.

      Thanks!
      Chris

  • http://chriskoenig.net Chris Koenig

    You should be able to RC on the web.config file and choose “Add Config Transforms”, which will create a transformation template for the current configuration. Give that a try and let me know if it does or doesn't work.

  • Peter Karaganis

    This is awesome, and a feature that has been needed for a loooooong time. The only issue I'm having, is that if I upgrade a vs2008 application, the config file doesn't have the drill down to the various build configuration versions. Any thoughts?

  • http://chriskoenig.net Chris Koenig

    You should be able to RC on the web.config file and choose “Add Config Transforms”, which will create a transformation template for the current configuration. Give that a try and let me know if it does or doesn't work.

  • Ken Bonnin, Jr

    What a fantastic tutorial. I understood the concept, but couldn’t glean from any of the MS documentation about how to develop and test config files. Much thanks!