Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio: differentiate app.config for debug and release mode

Is there a way to automatically use a separate app.config when building in release mode?

In other words, I want to test with one app.config, and release with another.

Currently, I keep a separate copy called app.config.production, and manually overwrite bin\Release\Application.exe.config after building for release.

like image 717
Korey Avatar asked Aug 18 '09 17:08

Korey


People also ask

What is the difference between debug mode and Release mode in Visual Studio?

Visual Studio projects have separate release and debug configurations for your program. You build the debug version for debugging and the release version for the final release distribution. In debug configuration, your program compiles with full symbolic debug information and no optimization.

What is the difference between a debug build and a Release build?

Major differences are the debug apk and the release apk: For debug builds the apk will be signed with the default debug signing keys with debug flag enabled. For release apk you will have to explicitly specify the apk to sign with and the debug flag will be turned off so that it cannot be debugged.


2 Answers

I have recently posted a supremely belated response to a similar SO topic: https://stackoverflow.com/a/27546685/2798367

I will repeat it here for clarity:

This is somewhat late to the party, but I stumbled upon a nice way of implementing the web.transform approach for app.config files. (i.e. it makes use of the namespace http://schemas.microsoft.com/XML-Document-Transform)

I think it is "nice" because it is a pure xml approach and doesn't require 3rd party software.

A parent / default App.config file is descended from, according to your various build configurations. These descendants then only override what they need to. In my opinion this is much more sophisticated and robust than having to maintain x number of config files which get copied in their entirety, such as in other answers.

A walkthrough has been posted here: http://mitasoft.wordpress.com/2011/09/28/multipleappconfig/


Look, Mom - No explicit post-build events in my IDE!

like image 32
ne1410s Avatar answered Oct 17 '22 21:10

ne1410s


Unload the project in Solution Explorer via the context menu.

Edit the .csproj file via the context menu and add this:

<PropertyGroup>     <AppConfig>App.$(Configuration).config</AppConfig> </PropertyGroup> 
like image 156
trueboroda Avatar answered Oct 17 '22 21:10

trueboroda