redman
redman

Reputation: 2165

Hide files in .csproj without excluding them from build

Is it possible to hide files/folders in .net core csproj without excluding them from build? I have a folder containing generated files which I would rather see they are not visible inside Solution Explorer in Visual Studio.

Upvotes: 26

Views: 10984

Answers (2)

Luke Vo
Luke Vo

Reputation: 20668

Thanks to Martin answer, I found a way to apply it to a whole folder using **\**. For example for an ASP.NET Core wwwroot\Scripts folder which contains files compiled by TypeScript (TypeScriptCompile):

    <ItemGroup>
        <TypeScriptCompile Update="wwwroot\Scripts\**\**" Visible="False" />
        <Content Update="wwwroot\Scripts\**\**" Visible="False" />
    </ItemGroup>

As his answer noted, you can add more type in there like None.

Upvotes: 0

Martin Ullrich
Martin Ullrich

Reputation: 100581

You can set the Visible="false" attribute on the items.

For an SDK-based project (.net core / asp.net core templates), you could add e.g.:

<ItemGroup>
  <Content Update="**/*.css" Visible="false" />
</ItemGroup>

Depending on your project type (=> defaults), you might have to replace Content with None for the particular type, or even Compile for generated code files.

Upvotes: 49

Related Questions