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

Korey picture Korey · Aug 18, 2009 · Viewed 43.4k times · Source

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.

Answer

trueboroda picture trueboroda · May 16, 2018

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>