Web Deployment and Config Transformations

If you are developing locally, you probably have a local testing environment. If you don't, you really need to investigate this and look to get an environment for testing (but that is content for another post). I recently became aware of configuration file transformations to match the environment you are deploying to. Essentially, you can deploy specific configuration in your web.config file based on the deployment profile you select.

I have listed a great article below that describes the process in detail, but the main idea is that you have multiple web.config files in your project (they are actually "stored" under your regular web.config file. You can find it by expanding the "plus sign" next to your web.config file).

You should notice a Web.Debug.Config and a Web.Release.Config file listed. If you were to look at your Publishing Profiles, you would notice that these files match the profiles listed ie Debug and Release profiles.

Therefore, when you publish using the Debug publishing profile, the configuration in the Web.Debug.Config file is deployed with your project. Similarly, using the Release profile will deploy the Web.Release.Config file.

This is great news for connection strings and other variables that are different based on the environment. No more need to backup web.config file in the publishing destination so that you don't lose your configuration. Now, the configuration will be pushed from your development environment to deployment.

Here is an article that describes the process in greater detail - http://blogs.msdn.com/b/webdev/archive/2009/05/04/web-deployment-web-config-transformation.aspx.

Enjoy. Til next time ..