How to put app.config under app.config?

Viewed 1357

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?

2 Answers

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>

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.

Related