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 of hello world takes way too long

See original GitHub issue

Reported by @migueldeicaza

Steps to reproduce

  1. dotnet new console
  2. dotnet build
  3. dotnet run

Expected behavior

dotnet run executes fast, nearly the same as calling dotnet <pathToDll>

Actual behavior

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 that run is calling msbuild twice before actually running the app: image

Can’t we have a fast-path here that bypasses MSBuild? It seems like we’ve optimized for incremental build via the run command which I’m not sure is really the primary workflow for run (but I may be wrong).

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:30
  • Comments:60 (28 by maintainers)

github_iconTop GitHub Comments

18reactions
omajidcommented, Sep 7, 2017

I believe dotnet run --no-build will help here. Maybe it should be the default.

7reactions
DamianEdwardscommented, Mar 9, 2021

We’re investigating CLI performance for the commands frequently used during development as part of .NET 6 and we definitely expect to get improvements to this very common scenario of running a simple app via dotnet run.

As it stands today, using a nightly build of .NET 6.0-preview.3, a dotnet run on a “Hello, World!” console app takes about 1.3-1.4 seconds on my machine, after a warm-up run or two. Running the app directly takes ~60ms, so the dotnet run overhead is practically the entire time, which is mostly spent in the the execution of the restore and build itself.

Progress on this work can be followed at https://github.com/dotnet/msbuild/issues/5876

Read more comments on GitHub >

github_iconTop Results From Across the Web

Printing "Hello World" to the terminal takes a very long time
I know that sounds like the lazy way to do it, but with just a short 'hello world' program, you shouldn't need to...
Read more >
.NET 6 compilation speed on macOS Monterey - am I ...
I'm on a M1 (Air I think? literally the cheapest one I could get), build times are 1.33 seconds for an ASP.NET hello...
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 >
dotnet watch command - .NET CLI
The dotnet watch command is a file watcher that runs a dotnet command when changes in source code are detected.
Read more >
ASP.NET Tutorial | Hello World in 5 minutes
Step-by-step instructions for installing .NET and building your first Hello World web application. Develop with free tools for Linux, macOS, and Windows.
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