Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exclude folder in ASP.NET Core 2

How can I exclude my X folder from the build?

If I remove it manually and dotnet build and dotnet run it takes along the lines of 20 seconds to run both commands and get me a working server.

On the other hand if I include it manually it takes something like 2 minutes to run both commands.

I've tried adding:

<ItemGroup>
    <Compile Remove="X\**" />
    <Compile Remove="wwwroot\**" />
    <Content Remove="X\**" />
    <EmbeddedResource Remove="X\**" />
    <None Remove="X\**" />
</ItemGroup>

to my .csproj file, but that doesn't seem to solve the issue.

So how can I instruct dotnet to ignore that folder completely?

like image 630
Shoe Avatar asked Oct 17 '17 16:10

Shoe


1 Answers

To exclude large folders to speed up the build, the items need to be excluded from the "default" items (the pattern searched by default) since the most time is spent searching the folder (though MSBuild 15.5 will contain optimisations for that).

Add this to the project file to exclude large folders that should never be searched in the first place:

<PropertyGroup>
  <DefaultItemExcludes>$(DefaultItemExcludes);my_large_folder\**</DefaultItemExcludes>
</PropertyGroup>
like image 167
Martin Ullrich Avatar answered Oct 13 '22 00:10

Martin Ullrich