Different appSetttings for each developer in the team - part II

Posted by Marcus Hammarberg on October 22, 2010
Stats
In my last post I asked for comments, and it didn't take Anders (Granåker) very long time to come up with a better and more correct solution to the problem.

The downside of my solution is that you need to tweak the build process on a build server for example. We knew that BUT I left it for later solving. There is a rename to be done and a moving of the real app.config etc.

OK - the solution has to do with the file-attribute on the AppSettings-node in .config-files. With that attribute you can point to another file that contains one or more keys from the appSettings-node. Two important things about that:

  1. If the file is not present it will use the settings in the original app.config
  2. If the file is present the settings in it will override any attributes that are specified in both places
Here is what we did:
We created a localAppSettings.config that contains the AppSettings that we want to override. Please note that this only contains . No -nodes in here. Here is what it looks like:


We then changed the app.config to contain our standard configuration and to point to the localAppSettings.config. Please note that the path is relative TO THE PLACE WHERE THE TEST ARE RUN. In my case that was in C:/Dev/Puls/Dev/PulsNet/GUI/PulsGui/LF.LIV.PEAAT/TestResults/localadmin_LF-E7A7A8B75E99%202010-10-22%2009_17_31/Out/ so the relative path is ... strange.
Here is how our app.config appsettings look like:

Finally we set the localAppSettings.config to be excluded from source control as I explained in the last post.

This solution is much nicer with a lower impact for everyone... including the build server.
Thanks Anders!


Published by Marcus Hammarberg on Last updated