If you’ve ever worked with web projects, you’ve probably used a functionality that allows you to have a different configuration file in the application (web.config), for different build modes (by default are DEBUG or RELEASE). If you want to see a post explaining this operation, this one is great > MSDN.
Initially this functionality does not come “out of the box” for other types of projects. Although it is possible to implement the same pattern using the “Configuration Transform” AddIn for Visual Studio. Here is an example for a WPF project.
We start from a project that has a defined Setting and a unique App.Config
To add a specific settings for the DEBUG and RELEASE builds, we select the App.config, deploy the contextual menu and select “Add Config Transforms”.
This action will add 2 dependent files of the App.Config, for each type of configuration.
If we open the file release, we will see that it is empty. If for example we have the Setting “SomeSpecial” value to Release, we can add the following code:
The code of the above definition, described in line 7, the < setting > node to be replaced when you find a match with the “name” attribute. In this way this value will be replaced when a compilation generated in Release mode.
Using this feature, can we make sure not “deploy wrong values to release environments”, values that we use in DEBUG in our dev environment.
Greetings @ Home