Hack the Build: Hide Items from Visual Studio Solution Explorer

Jomo Fisher -- Custom MSBuild projects and targets files that you write typically have ItemGroups to contain lists of files. For example,

<ItemGroup>
<MyFiles Include="a.txt"/>
</ItemGroup>

When you fire up VS with the above code in a project you'll find that "a.txt" shows up in the solution explorer. Depending on how you intend these items to be used you might be delighted by this or you might be annoyed. You'll be annoyed if the ItemGroup is a private implementation detail and should not be in the user's face.

If this has happened to you, try this:

<ItemGroup>
<MyFiles Include="a.txt">
<InProject>false</InProject>
</MyFiles>
</ItemGroup>

The InProject metadata will not affect the build at all. It just tells Visual Studio that you don't want the item displayed in Solution Explorer.

This posting is provided "AS IS" with no warranties, and confers no rights.