aspnetcore: Dotnet Watch Run indefinitely reloads
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
dotnet new consoledotnet watch run- 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
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 3
- Comments: 21 (14 by maintainers)
I’m seeing the same thing for
dotnet watch.Note that I am on macOS 12.0.1 with dotnet 6.0.1.
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.30045 seconds… if you’re lucky @CommonLoon102. 😛 I still have yet to see this feature work well or at all in my environment.
It does work but it takes 45 seconds to complete though. https://github.com/dotnet/razor-tooling/issues/7626
Could someone comment whether hot reload is supposed to work in a Blazor Server app?
@pranavkm @mkArtakMSFT
I can reproduce this by adding one line to a fresh Blazor Server project.
<DefaultAppHostRuntimeIdentifier>win-x64</DefaultAppHostRuntimeIdentifier>Can confirm the same issue here (Windows 11, dotnet 6.0.101)