At some point my project build started taking a long time. It's not a large project and it's directly related to the node_modules
directory which is at the root of the project, and excluded from the project!
<PropertyGroup>
<DefaultInstallExcludes>packages\**</DefaultInstallExcludes>
<DefaultInstallExcludes>$(DefaultInstallExcludes);**\node_modules\**;node_modules\**</DefaultInstallExcludes>
</PropertyGroup>
<ItemGroup>
<InstallInclude Include="**\*.ascx" Exclude="$(DefaultInstallExcludes)" />
<InstallInclude Include="**\*.asmx" Exclude="$(DefaultInstallExcludes)" />
<InstallInclude Include="**\*.css" Exclude="$(DefaultInstallExcludes)" />
<InstallInclude Include="**\*.html" Exclude="$(DefaultInstallExcludes)" />
<InstallInclude Include="**\*.aspx" Exclude="$(DefaultInstallExcludes)" />
<InstallInclude Include="**\*.js" Exclude="$(DefaultInstallExcludes)" />
<InstallInclude Include="**\images\**" Exclude="$(DefaultInstallExcludes)" />
</ItemGroup>
It seems it's excluding all the files properly, but it's still scanning the entire directory. How can I get it to completely ignore the node_modules
folder entirely during a build? Tools version is 3.5. This used to take <30 seconds and at some point started taking ~10 minutes. VS Community 2019.
I think the issue is that InstallInclude
is your custom item rather than the system item. And most of the files of node_modules
are system items like None
or Content
.These are shown on the solution explorer and are scanned by msbuild.
The system build action are listed under this document .
What you did is make the new InstallInclude
item did not contain the files from node_modules
and packages
. But the system item which contains node_modules
folder, so it will always scan the folder.
Suggestion
You should exclude that folder from system Item.
For new-sdk projects, DefaultItemExcludes
does work but it does not work for net framework projects.
If your project target to Net Framework
, you should use any system item remove to remove those files.
Use this:
<ItemGroup>
<Content Remove="node_modules\**" />
<Compile Remove="node_modules\**" />
<EmbeddedResource Remove="node_modules\**" />
<None Remove="node_modules\**" />
<Compile Remove=node_modules\**" />
<TypeScriptCompile Remove="node_modules\**" />
.... any system item
</ItemGroup>
<PropertyGroup>
<DefaultInstallExcludes>packages\**</DefaultInstallExcludes>
<DefaultInstallExcludes>$(DefaultInstallExcludes);**\node_modules\**;node_modules\**</DefaultInstallExcludes>
</PropertyGroup>
<ItemGroup>
<InstallInclude Include="**\*.ascx" Exclude="$(DefaultInstallExcludes)" />
<InstallInclude Include="**\*.asmx" Exclude="$(DefaultInstallExcludes)" />
<InstallInclude Include="**\*.css" Exclude="$(DefaultInstallExcludes)" />
<InstallInclude Include="**\*.html" Exclude="$(DefaultInstallExcludes)" />
<InstallInclude Include="**\*.aspx" Exclude="$(DefaultInstallExcludes)" />
<InstallInclude Include="**\*.js" Exclude="$(DefaultInstallExcludes)" />
<InstallInclude Include="**\images\**" Exclude="$(DefaultInstallExcludes)" />
</ItemGroup>
Exclude from tsconfig files:
modify tsconfig.json
:
{
"compilerOptions": {
....
},
"include": [
...
],
"exclude": [
"node_modules"
],
.....
}
modify tsconfig.spec.json
file:
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/spec",
"types": [
"jasmine"
]
},
"files": [
....
],
"include": [
....
],
"exclude": [
"node_modules/**/*"
]
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.