Problem with file name folding in Visual Studio Solution Explorer ("File Nesting")
(Edit for search-ability: called "File Nesting")
I'm not sure if "folding" is the correct term, but the feature I'm referring to is shown in the 1st image below, versus the 2nd one which does not have an expandable tree list node for the code behind file.
- Folding:
- No folding:
My questions are:
- What is the correct name of this feature?
- How do I set it?
- Why does my Solution Explorer not have this feature enabled when I try to convert my Web Site Project to a Web Application Project?
References:
- Upgrading VS 2005 We开发者_如何学Gob Site Projects to be VS 2005 Web Application
Edit
Thanks Sean, but as you can see below, my Nest Related Files
button does show up in this project for some reason:
Should have button shown below:
Edit:
I figured out the reason: I accidentally created a C# Web Application Project, and then added VB ASP.NET files to it.
- It's called File Nesting.
- When a website project is selected in Solution Explorer, the third button in the Solution Explorer toolbar is for "Nest Related Files".
- A website project or project file must be selected in Solution Explorer (rather than the root Solution), for the button to appear in the toolbar. The command/tool button is not available when C++/C# projects are selected in Solution Explorer. I don't have a web app project to test but can only conclude that the command is not applicable to web app projects either.
see this related question for a possible registry hack (changing 9.0 to 8.0 in the question's reg script): Visual Studio 2010 related file nesting
When you are not using a website project, the nesting button in the solution explorer won't appear—but you can still nest files in .NET 5.0 projects.
Here's how you do it:
- Open the project's
.csproj
file. Visual studio can open it in its own viewer, or else you can use your favorite XML or text editor. - Locate or create an appropriate
Item Group
element. If there's already one that includes some of your files, put it in there for cleanliness and consistency. If there isn't, create a new one. - Create a new
Content
element for the file you wish to nest. This element'sInclude
attribute should be the name of your desired file. - Add a new
DependentUpon
child element to your content element. This element's text value should be the name of the file you wish to nest your target file underneath. - Save the project file and Visual Studio will likely prompt you to reload the project. If you did it correctly, your target file should now be nested under your desired file.
There's shockingly few questions and answers that address this situation. The above answer didn't help me, so I figured that I would share what did for posterity.
精彩评论