Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / web / ASP.NET

Per developer configuration files (Visual Studio)

0.00/5 (No votes)
13 Sep 2010CPOL2 min read 11.2K  
Per developer configuration files (Visual Studio)

Configuration files (such as app.config, web.config, etc.) are very convenient, but it's a real pain to manage them in a collaborative environment.

Although Microsoft introduced web.config transforms in Visual Studio 2010, it suffers (stop me if I'm wrong) from several limitations:

In my case (a team with a dozen of .NET developers on several ASP.NET projects, with Visual Studio 2005 and SVN as source control) which is probably next to yours, each developer was changing his configuration files with his own values (connection string, debug mode, etc.) and was periodically committing his changes, making other developers lose their values or have conflicts while updating (XML is badly merged with SVN).

I solved this problem by using NANT (http://nant.sourceforge.net) in all our .NET projects (Visual Studio 2005), basically:

  1. Genuine configuration files (such as web.config in an ASP.NET project) are moved as templates in a subfolder
  2. Hard coded values must be replaced with ${your_property} properties
  3. Genuine configuration files must be ignored in your source control server
  4. Each developer should create his property file (whose name must include at least the current Windows username), with customized values for ${your_property} properties
  5. A NANT's build file must be created, it's aim is to load the current Windows username property file, then copy the templated configuration files to their genuine place (properties must be extended)
  6. NANT must be triggered during the Visual Studio's pre-build event, to execute the build file

That's all folk, now each developer can manage his own property file (which can be/must be stored in your source control server) independently of the machine he's logged (as long as the Windows username is the same of course!).

Depending on your needs, you can extend this principle with the machine name, the current configuration, etc.

You can contact me if you want further information.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)