Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Group files in Visual Studio

I'm looking at tidying up my project layout in Visual Studio and I'm wondering if there is any hack, plugin or trick to associate an .xml file with a .cs file of the same name so they appear grouped in my solution navigator/explorer.

Similar to the way the code-behind file is associated with its aspx.

alt text

Any suggestions welcome. Thanks

like image 270
mat-mcloughlin Avatar asked Sep 01 '10 11:09

mat-mcloughlin


People also ask

How do I nest files in Visual Studio?

The precedence for merging file nesting settings is: Visual Studio > Solution > Project. You can tell Visual Studio to ignore solution-specific and project-specific settings, even if the files exist on disk, by enabling the option Ignore solution and project settings under Tools > Options > ASP.NET Core > File Nesting.

How do I run multiple files in Visual Studio?

Visual Studio allows you to specify how more than one project is run when you press F5 (Start with Debugging), or Ctrl+F5 (Start without debugging), or use the toolbar button to launch your application.

What is the Solution Explorer in Visual Studio?

Solution Explorer is a special window that enables you to manage solutions, projects, and files. It provides a complete view of the files in a project, and it enables you to add or remove files and to organize files into subfolders.


2 Answers

In your project file :

<Compile Include="FileA.cs"/> <Compile Include="FileA.xml">   <DependentUpon>FileA.cs</DependentUpon> </Compile> 

Or you could use Group Items command of VSCommands 2010 extension.

Edit: Just in case your file is in a folder, don't include the folder name in DependentUpon tag. For example if your file is in Helpers folder:

<Compile Include="Helpers\FileA.cs"/> <Compile Include="Helpers\FileA.xml">   <DependentUpon>FileA.cs</DependentUpon> </Compile> 
like image 135
Julien Hoarau Avatar answered Sep 21 '22 16:09

Julien Hoarau


If you do not want to slow down you IDE with heavy and proprietary VSCommands extension you can use small extension NestIn instead. It can nothing but group/ungroup files

like image 26
Dao Avatar answered Sep 17 '22 16:09

Dao