Group files in Visual Studio

Viewed 25694

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

6 Answers

In .NET (Core+)

<ItemGroup>
  <Compile Update="FileA.*.cs">
    <DependentUpon>FileA.cs</DependentUpon>
  </Compile>
</ItemGroup>

Note that Update is used instead of Include where files are already (implicitly) included in the project and use of Include causes compile-time "Error NETSDKxxxx Duplicate 'Compile' items were included... The duplicate items were: 'FileA.xxxx.cs' C:\Program Files\dotnet\sdk\x.x.x.x\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.DefaultItems.Shared.targets"

See Is there a DependentUpon option in a .net core app?

Related