Every <Compile> item in my project takes up 3 lines of XML. Is there a way to clean this up?
You may be noticing the following pattern in your project file (.CSPROJ, etc.):
[<ItemGroup>]
<Compile Include="Foo1.cs">
[<SubType>Code</SubType>]
</Compile>
<Compile Include="Foo2.cs">
[<SubType>Code</SubType>]
</Compile>
...
<Compile Include="FooN.cs">
[<SubType>Code</SubType>]
</Compile>
[</ItemGroup>]
This is indeed quite verbose for just storing a list of files. If you want to clean it up, you can change it to this:
[<ItemGroup>]
<Compile Include="Foo1.cs; Foo2.cs; FooN.cs">
[<SubType>Code</SubType>]
</Compile>
[</ItemGroup>]
VS will load this just fine, but there is one downside to this. If you rename/delete/exclude any of the files in the list through the VS Solution Explorer, then we will explode your list into individual <Compile> tags ... just like the more verbose version that you thought was so messy. If you don't rename/delete/exclude any of the files through VS, then it will leave your syntax alone. The preservation of your customizations to the project file may only work correctly with ""Beta 1"" and beyond.
Another possibility that works for most cases is to leave off ""SubType"" entirely. The ""SubType"" is really only needed for Forms which need to pop open the Winforms designer in the Visual Studio IDE. If most of your .CS files are just regular old .CS files (not forms), then just kill the ""SubType"". The lack of a ""SubType"" attribute is the same as having ""SubType"" set to "Code". Taking advantage of this fact can clean things up quite a bit:
[<ItemGroup>]
<Compile Include="Foo1.cs; Foo2.cs; FooN.cs"/>
[</ItemGroup>]
We have a bug open that says that VS persists the ""SubType"" even when it doesn't need to ... and we'll definitely get that fixed before we ship VS 2005.