I tried adding a new web.config file to my asp.net app (I went through right click on the project -> add -> Web Configuration File).
However at the Solution Explorer the newly added file is not nested under Web.config. Any idea?
See image -
I would like Web.Staging.config to be nested just as Web.Release.config:
(Assume VS 2012 or 2013).
Asked
Active
Viewed 1.0k times
14

Wai Ha Lee
- 8,598
- 83
- 57
- 92

Erez Cohen
- 1,507
- 2
- 16
- 25
-
why do you want it like that?? – Amit Joki Apr 01 '14 at 11:42
-
1possible duplicate of [how to add files in web.config transformation process?](http://stackoverflow.com/questions/15542421/how-to-add-files-in-web-config-transformation-process) – Mahmoud Darwish Apr 01 '14 at 11:49
-
It was indeed a duplicate of the above question. Sorry, couldn't find it. However the answer that worked for me is not the accepted one but [this one](http://stackoverflow.com/a/16825153/145599). – Erez Cohen Apr 01 '14 at 13:00
3 Answers
25
If all you want is nesting, you could just open your csproj file in a text editor and change this:
<None Include="Web.Staging.config" />
to this:
<None Include="Web.Staging.config">
<DependentUpon>Web.config</DependentUpon>
</None>

Marcus
- 338
- 3
- 5
-
This works fine for local Project files. However if you have a config file linked from a Solution folder as a link, there is no error but the DependentUpon tag does not render the item as a child in Solution Explorer. It's really a non-issue though. – Muster Station Sep 26 '16 at 16:09
7
Take a look at this blog.
Specifically:
To add configuration specific transform file (e.g. Web.Staging.Config) you can right click the original web.config file and click the context menu command “Add Config Transforms”

Joe
- 122,218
- 32
- 205
- 338
-
5Thanks. I accepted this answer although the problem was that "Add Config Transform" option is disabled until you add a new build configuration. However in the blog post you sent there was another link that described that as well. – Erez Cohen Apr 01 '14 at 13:11
0
You can also currently use the File Nesting tool
https://marketplace.visualstudio.com/items?itemName=MadsKristensen.FileNesting

Edu_LG
- 1,500
- 1
- 13
- 11