Closed mcnallys closed 2 years ago
Good idea - I will have a look at this. We will probably put it behind a flag, but I don't see any harm in defaulting it to true.
As an alternative, I think DefaultItemExcludes
is actually designed for this scenario.
Could you try the following instead and see if it is any better or worse? I think it should be better and it won't add the items in the first place then remove them again.
<PropertyGroup>
<DefaultItemExcludes>$(DefaultItemExcludes);node_modules\**</DefaultItemExcludes>
</PropertyGroup>
You are correct about DefaultItemExcludes, I ended up needing a combination of both.
I also had to do this for every glob include I did,
<Content Include="**\*.js" Exclude="$(DefaultItemExcludes)" />
@mcnallys I think most people would be including Content\**\*.css
or Scripts\**\*.js
etc. rather than the open glob, but adding the Exclude="$(DefaultItemExcludes)"
obviously works too. In my case, *\.js would grab gulpfile.js
.
Do you think it is worthwhile adding
<PropertyGroup>
<DefaultItemExcludes>$(DefaultItemExcludes);node_modules\**</DefaultItemExcludes>
</PropertyGroup>
to the SDK? Or is it something that would be done by the consumer? I feel there might be other folders that would be excluded based on which package manager you were using,
Looking at the ASP.NET Core SDK I found the following lines:
<DefaultItemExcludes>$(DefaultItemExcludes);**\node_modules\**;node_modules\**</DefaultItemExcludes>
<DefaultItemExcludes>$(DefaultItemExcludes);**\jspm_packages\**;jspm_packages\**</DefaultItemExcludes>
<DefaultItemExcludes>$(DefaultItemExcludes);**\bower_components\**;bower_components\**</DefaultItemExcludes>
Yeah I would add those lines to the sdk, it took me quite a while to figure out what was going on.
@mcnallys If you update to Version 4.0.50 these lines will be included by default and you can remove them from your project file.
If you have a large project that is doing any kind of globbed includes and you have a large number of node_modules then the sdk project system will consume an inordinate amount of resources- often crashing with an out of memory error. It will also be extremely slow to do any project operations- adding a new file, etc.
Adding this solved the problem for me:
I think this should be included to avoid this pitfall.