sdk: Slow performance using dotnet restore & build with deep folder structure
Steps to reproduce
Create a new .NET Core project
mkdir MyProject
cd MyProject
dotnet new mvc
Create an embedded client app using create-react-app
mkdir client
cd client
create-react-app .
Restore the .NET Core application
cd ..
dotnet restore MyProject.csproj
Expected behavior
The expectation is that the restore should be very fast or at least as fast with the project.json version of the sdk.
Actual behavior
Restoring the application’s packages is terribly slow, probably due to the deep directory structure which node creates.
Environment data
dotnet --info output:
.NET Command Line Tools (1.0.0-rc4-004771)
Product Information: Version: 1.0.0-rc4-004771 Commit SHA-1 hash: 4228198f0e
Runtime Environment: OS Name: Mac OS X OS Version: 10.12 OS Platform: Darwin RID: osx.10.12-x64 Base Path: /usr/local/share/dotnet/sdk/1.0.0-rc4-004771
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 1
- Comments: 20 (11 by maintainers)
Assuming you only want to publish the built output and not all development folders, you can exclude folders from being published - including the
node_modulesfolder. If I add:<DefaultItemExcludes>$(DefaultItemExcludes);client\node_modules\**</DefaultItemExcludes>as property,dotnet publishonly takes 3.2 seconds instead of 15.Looks like msbuild is taking long to expand the globs brought in via the web sdk. The targets themselves don’t take very long to run (note that I never ran restore or build, just clean):
If I add
<EnableDefaultItems>False</EnableDefaultItems>to the project, the same invocation only takes a second (a tenth of the time).Looks like this has been fixed in the web sdk for the upcoming release https://github.com/aspnet/websdk/blob/dev/src/ProjectSystem/Microsoft.NET.Sdk.Web.ProjectSystem.Targets/netstandard1.0/Microsoft.NET.Sdk.Web.ProjectSystem.props#L15
Yes, clean has the same behaviour…
dotnet clean