开发者

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.

  1. Folding:

Problem with file name folding in Visual Studio Solution Explorer ("File Nesting")

  1. No folding:

Problem with file name folding in Visual Studio Solution Explorer ("File Nesting")

My questions are:

  1. What is the correct name of this feature?
  2. How do I set it?
  3. 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:

Edit

Thanks Sean, but as you can see below, my Nest Related Files button does show up in this project for some reason:

Problem with file name folding in Visual Studio Solution Explorer ("File Nesting")

Should have button shown below:

Problem with file name folding in Visual Studio Solution Explorer ("File Nesting")

Edit:

I figured out the reason: I accidentally created a C# Web Application Project, and then added VB ASP.NET files to it.


  1. It's called File Nesting.
  2. When a website project is selected in Solution Explorer, the third button in the Solution Explorer toolbar is for "Nest Related Files".
  3. 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:

  1. 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.
  2. 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.
  3. Create a new Content element for the file you wish to nest. This element's Include attribute should be the name of your desired file.
  4. 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.
  5. 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.

Problem with file name folding in Visual Studio Solution Explorer ("File Nesting")

Problem with file name folding in Visual Studio Solution Explorer ("File Nesting")

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜