Wednesday, September 17, 2008

How to be with config files

Often (more precisely - always) we meet the situation where we should store information in configuration files. But when we commit this files to our Version Control System other developers obtain our settings and try to connect to our DB, web service etc.

How to avoid such situation?

Just use templates.

Instead of commiting Web.config, for example, you create Web.config.template that is the copy of Web.config and commit it.

Then every developer during first obtaining of sources renames template file into necessary one and change configuration parameters.

It also helps with build automation - you store config file with the settings that are good for automation server. During every commit (or by schedule - it depends on how you configure you Continuous Integration server) scripts rename files and compilation and unit testing passed successfully.

One tip: templates should contain such default values that allow to build and run tests successfully without changing them in standard environment.

No comments: