views:

271

answers:

3

As an example we have a Unit Test Project with an app.config file. The app.config file is configured to work on our build server. But if we want to run our tests locally (with local database) we have to change the app.config...everytime... is there a way to never alter the app.config but to have another file that overrides the app.config configuration? (so that nobody by accident commits a corrupt app.config in subversion?)

(the same off course counts for web.config, ...)

thx, Lieven Cardoen

+2  A: 

I might be re-inventing the wheel, but you could create multiple app.config files in SubVersion (app.config.release, app.config.debug) then add post build events to copy these files to app.config on developers machines.

I would then avoid putting app.config itself in Subversion at all, you can use app.config.production or similar to store the contents of the file.

Richard Slater
And locally you would need to rename one of the app.config.* files? Problem is if you need to add something to the web.config, you'll need to add it to a couple of other app.config.* files...I wonder how this is done with Team Foundation Server...
Lieven Cardoen
@Richard: This is exactly what we do, and it works pretty well. The only thing is that changes to the .config file has to be made to all versions of it before checking it in. Supposedly, enhancements to .NET are coming down the pipe to make this easier.
Matt Peterson
+1  A: 

How about a small script (I would do it in Perl) for each config that performs the necessary changes to convert the relevant part(s) in the app.config to a local config, server config, etc..? You could have one separate project configuration for each script and call the script in the post build event.

Adrian Grigore
+2  A: 

Would the 'file' attribute of the appSettings element help? (MSDN)

It allows you to provide a seperate file that can override selected values from the main app.config (or web.config).

chyne