samedi 11 septembre 2010

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 environnement.

Although Microsoft introduced web.config transforms in Visual Studio 2010, it suffers (stop me if I'm wrong) from several limitations :
- it don't permit to make per developer web.config
- it only works for web.config (a workaround exists for app.config)

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) who is probably next to yours, each developer was changing it's configuration files with it's own values (connection string, debug mode, etc.) and was periodicaly commiting it's changes, making other developers loose their values or have conflicts while updating (XML are 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 remplaced 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 it's own property file (who can be/must stored in your source cotrol server) independently of the machine he's logged (as long as the Windows username is the same of course !)

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

Check out the full featured article on .

You can either contact me if you want more informations.

Aucun commentaire: