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 Watch Run indefinitely reloads

See original GitHub issue

Describe the bug

Calling dotnet watch run will detect changes continuously and loop forever.

The first time a file is changed, the Program will rebuild and run. But, after that it will continuously rebuild and reload, even without changing the file.

Workaround, run dotnet watch run --no-hot-reload and it will behave as desired (ie: only reloading when a file actually changes).

Environment: WSL2

To Reproduce

  1. dotnet new console
  2. dotnet watch run
  3. Save “Program.cs”

Observe that the program will constantly restart.

watch : Started
watch : Exited
watch : Waiting for a file to change before restarting dotnet...
watch : Building...
  UnregisteredDeviceSearch -> /home/jamesikanos/scratch/UnregisteredDeviceSearch/bin/Debug/net6.0/UnregisteredDeviceSearch.dll
watch : Started
watch : Exited
watch : Waiting for a file to change before restarting dotnet...
watch : Building...
  UnregisteredDeviceSearch -> /home/jamesikanos/scratch/UnregisteredDeviceSearch/bin/Debug/net6.0/UnregisteredDeviceSearch.dll
watch : Started
watch : Exited

Exceptions (if any)

No exception

Further technical details

Running on VSCode. This behaviour is also observed when running dotnet watch run from Ubuntu terminal.

.NET SDK (reflecting any global.json): Version: 6.0.100 Commit: 9e8b04bbff

Runtime Environment: OS Name: ubuntu OS Version: 20.04 OS Platform: Linux RID: ubuntu.20.04-x64 Base Path: /usr/share/dotnet/sdk/6.0.100/

Host (useful for support): Version: 6.0.0 Commit: 4822e3c3aa

.NET SDKs installed: 2.1.816 [/usr/share/dotnet/sdk] 3.1.410 [/usr/share/dotnet/sdk] 6.0.100 [/usr/share/dotnet/sdk]

.NET runtimes installed: Microsoft.AspNetCore.All 2.1.28 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.28 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.16 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.0 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.28 [/usr/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.16 [/usr/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.0 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET runtimes or SDKs: https://aka.ms/dotnet-download

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:21 (14 by maintainers)

github_iconTop GitHub Comments

3reactions
mrlifecommented, Dec 20, 2021

I’m seeing the same thing for dotnet watch.

% dotnet watch
watch : Hot reload enabled. For a list of supported edits, see https://aka.ms/dotnet/hot-reload. Press "Ctrl + R" to restart.
watch : Building...
  Determining projects to restore...
  All projects are up-to-date for restore.
  MyProject -> /Users/username/projects/MyProject/bin/Debug/net6.0/MyProject.dll
watch : Started
watch : Building...
  MyProject -> /Users/username/projects/MyProject/bin/Debug/net6.0/MyProject.dll
watch : Started
watch : Building...
  MyProject -> /Users/username/projects/MyProject/bin/Debug/net6.0/MyProject.dll
watch : Started
watch : Building...

Note that I am on macOS 12.0.1 with dotnet 6.0.1.

1reaction
javiercncommented, May 19, 2022

Reproduced in a repl.it notebook: https://replit.com/@ripley/DotnetWatchRepro#README.md

This seems like a pretty big bug in dotnet watch and I hope it can get addressed.

I correct myself. netcoreapp6.0 works, but the issue is with <StartupObject>Program</StartupObject> and top level statements. As far as I can tell this is already addressed in 6.0.300

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dotnet watch run - Force reload on "rude edit" - .Net 6
The project/browser reloads when I make a change. Awesome! However, sometimes I will be shown this: Unable to apply hot reload because of...
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 >
Why doesn't Hot Reload work? : r/Blazor
I haven't been able to get it working yet either. I'm still sticking with the trusty “dotnet watch run” command executed from the...
Read more >
.NET 6 Hot Reload and "Refused to connect to ws ...
Hm, self seems reasonable, why can't the browser connect BACK to the dotnet run'ed Kestrel Web Server? It's all localhost, right? Well, ...
Read more >
NET 6 Hot Reload support
Hi,Does the project support Hot Reload introduced in .NET 6? ... This took forever and VS stopped responding: ... dotnet watch run --no-build...
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