Slow performance using dotnet restore & build with deep folder structure
See original GitHub issueSteps 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
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:20 (11 by maintainers)
Top Results From Across the Web
Slow performance using dotnet restore & build with deep ...
Restoring the application's packages is terribly slow, probably due to the deep directory structure which node creates. Environment data. dotnet ...
Read more >dotnet core 2 long build time because of long restore time
I noticed that building in dotnet core 2 seemed a lot slower. But the timing after the build always showed 'only' 15 seconds....
Read more >.NET 6 compilation speed on macOS Monterey - am I ...
I have built a blank console app with dotnet new console , but I am kind of shocked by how slow the compile...
Read more >Performance Improvements in NuGet - Visual Studio Blog
At its core, restore ensures that all your dependencies, declared in either the project file or packages.config, are available prior to build.
Read more >Docker build caching for .NET applications done right with ...
The suggested solution is to copy all the csproj files manually while preserving the original folder structure.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Assuming you only want to publish the built output and not all development folders, you can exclude folders from being published - including the
node_modules
folder. If I add:<DefaultItemExcludes>$(DefaultItemExcludes);client\node_modules\**</DefaultItemExcludes>
as property,dotnet publish
only 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).