dotnet run of hello world takes way too long
See original GitHub issueReported by @migueldeicaza
Steps to reproduce
- dotnet new console
- dotnet build
- 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:
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:
- Created 6 years ago
- Reactions:30
- Comments:60 (28 by maintainers)
Top 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 >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 FreeTop 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
Top GitHub Comments
I believe
dotnet run --no-build
will help here. Maybe it should be the default.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 thedotnet 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