Sunday, January 16, 2011

Managing multiple web app configs

One of the most important things that you must do when building a web app is to keep distinct and separate configs for each environment. This is importnant because for one, your database will be different between development and production (and possibly testing and staging). You won’t want to actually send emails in development, and you’ll probably want to enable test mode for any payment providers or other third-party APIs. The list could go on – there are many use-cases and reasons why you should keep sepearate config. It boils down to this: you shouldn’t have to worry about changing these things when you’re ready to deploy or test.

This concept, and how to accoplish it, is a no brainer for Rails developers and even some PHP developers. In the .NET world this is a fiarly new concept and there hasn’t been much support for anything of the sort until recently. With VisualStudio 2010 Microsoft brought us the idea of config transforms. I’m not going to go into the details but basically you have to write xml transformations to customize your main config file. That wasn’t going to cut it for me so I set out to come up with a better plan. This is what I came up with.
NOTE: This is in the context of a ASP.NET MVC project.
Inside our web project we have a standard web.config file. We also have a Config folder, with a folder insie for each environment. This one has four environments, development, production, staging and test.

Read more: David Radcliffe