Mikael Dúi Bolinder
Mikael Dúi Bolinder

Reputation: 2287

How to put app.config under app.config?

I'm trying to create multiple app.config's for different build profiles, like app.debug.config and app.release.config. How do I put them under each other in Solution Explorer?

Upvotes: 2

Views: 2154

Answers (2)

sondos eleswed
sondos eleswed

Reputation: 44

By right-click on app. config and click on add config transforms. if you can't find the add config transform you should download the configuration transform from manage Extentions in vs.

Upvotes: 0

Martin Ullrich
Martin Ullrich

Reputation: 100543

The visual representation is based on the DependentUpon metadata in the csproj file.

For example when you have 3 config files, you can set the metadata as such:

<None Include="App.config" />
<None Include="App.Debug.config" DependentUpon="App.config" />
<None Include="App.Debug.BackupDb.config" DependentUpon="App.Debug.config" />

which results in the following representation in the solution explorer:

enter image description here

For older versions (pre-VS 2017) you will need to add the DependentUpon metadata as elements beneath the None element instead of adding it as attribute.

To be compatible with VS 2015 and lower, the xml for the item would be:

<None Include="App.Debug.config">
  <DependentUpon>App.config</DependentUpon>
</None>

Upvotes: 4

Related Questions