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:
- If the file is not present it will use the settings in the original app.config
- 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: