Eric Jensen

Hi,

I have files in various subdirectories that I want to include in the Solution Explorer. It is getting a little tedious to "Add Existing Item" with a link (sometimes I click the button before changing it to "link" whereby I have to delete the copied file - bad UI design IMO). The files appear as a flat list in the explorer which is also a pain.

I've discovered I can use <CSFile Include="..\Display\*.cs/> in my .csproj file to avoid having to enter every file manually.

However, I still have a few problems:

1) I still get a flat file list in the solution explorer. I've tried using <Filter ...> (used in .vcproj files) but VS doesn't like it.

2) I haven't figured out how to identify forms and link partial classes together. E.g. How do I tag "../Display/ChartWindow.cs" as a <SubType>Form</SubType> and how I can associate "../Display/ChartWindow.designer.cs" with "../Display/ChartWindow.cs". Interestingly, VS picks up the .resx relationship.

Any help appreciated. I've run out of terms to Google. There does not appear to be a central document describing the .csproj schema (even the MSBUILD schema does not appear comprehensive i.e. CSFile - let alone providing helpful documentation).

Many thanks.



Re: Visual C# IDE Grouping files in solution explorer

Mark Benningfield

Hello All.

ehjensen:

This snippet might be of use to you:


<ItemGroup>
<
Content Include="..\..\..\..\My Images\images\Education\CBR003161_LoRes.jpg">
<
Link>NewFolder1\CBR003161_LoRes.jpg</Link>
</
Content>
<
Content Include="NewFolder1\CBR003860_LoRes.jpg" />
</
ItemGroup>


The first content tag is a file included as a link, in a sub-folder in Solution Explorer named NewFolder1, and second content tag is a file included by copy, in the same sub-folder.

HTH.






Re: Visual C# IDE Grouping files in solution explorer

Eric Jensen

That works like a charm for individual files. Thank you!

Any thoughts about how this might work with globbing (e.g. *.cs) I've tried a few variations inc'l <link>foo\*.cs</link> to no avail.




Re: Visual C# IDE Grouping files in solution explorer

Mark Benningfield

Hello All.

Eric:

I'm not sure you could make that work straight from the .csproj file. You'd probably have to have some kind of intermediary script acting on an XML source file, like an XLST or something. The content tags are individual items, so you'd have to have the "*.cs" situated in a source XML file that the XLST would transform into the .csproj file.

HTH.






Re: Visual C# IDE Grouping files in solution explorer

Eric Jensen

Thank you Mark!




Re: Visual C# IDE Grouping files in solution explorer

Mark Benningfield

Hello All.

Eric:

You're welcome. I did a little poking around MSDN, and found this. It might be useful.

HTH.






Re: Visual C# IDE Grouping files in solution explorer