question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"dotnet run" went from 4 seconds to 45 seconds to lauch project

See original GitHub issue

Looks like dotnet is scanning the complete directory rather than specifying a ‘launch’ .cs file and following dependencies used from that file. Equally, it would be good to be able to specify different launch commands under one git repo to manage different process types, for example:

> dotnet run worker_imageprocessor.cs
> dotnet run kestel_server.cs

Steps to reproduce

Working on a small app, c# backend, react frontend. Used ‘create-react-app & npm install’ to create a folder ‘frontend’ under project directory (common directory structure in nodejs projects)

Expected behavior

Expected this would have no impact on dotnet cli as the frontend folder has no files related to the backend build process, however.

Actual behaviour

It caused every dotnet run to take 10x longer.

Environment data

.NET Command Line Tools (2.0.0)

Product Information: Version: 2.0.0 Commit SHA-1 hash: cdcd1928c9

Runtime Environment: OS Name: Windows OS Version: 10.0.15063 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\2.0.0\

Microsoft .NET Core Shared Framework Host

Version : 2.0.0 Build : e8b8861ac7faf042c87a5c2f9f2d04c98b69f28d

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
benaadamscommented, Aug 29, 2017

Try adding excludes to .csproj for node_modules https://github.com/dotnet/cli/issues/7525#issuecomment-324998276

e.g.

<PropertyGroup>
  <DefaultItemExcludes>node_modules/**;$(DefaultItemExcludes)</DefaultItemExcludes>
</PropertyGroup>
0reactions
peterhuenecommented, Mar 28, 2018

The fix I described above is now checked in. This should improve performance of dotnet run --no-build dramatically and reduce the overall time of just dotnet run by a considerable amount when run in directories containing a large set of files, even without DefaultItemExcludes set.

I still recommend setting that property to exclude unnecessary directories from being globbed for the build, though.

Thank you for reporting this issue to us, @khowling.

Read more comments on GitHub >

github_iconTop Results From Across the Web

dotnet run of hello world takes way too long · Issue #8697
dotnet run is slow, about 3 seconds on my machine. It's consistently this slow, even when it doesn't need to rebuild. It appears...
Read more >
How can dotnet core 5 be so slow on simplest console app?
Solution: Turn off the laptop, remove the battery, wait for some time. Share.
Read more >
Speed up compilation of ASP.NET Core 2.1 projects
Right Click on Project and select Rebuild. At this point, compilation takes 45 seconds and is the same on every rebuild. If I...
Read more >
Performance Improvements in .NET 7
NET 7 is fast. Really fast. This post deep-dives into hundreds of performance improvements that contributed to that reality.
Read more >
Speed of dotnet run vs the speed of dotnet for published ...
It'll be about 3-4 seconds. dotnet is the SDK and dotnet run will build and run your source code. Here's a short bit...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found