dotnet watch exits immediately without starting server when DOTNET_WATCH_SUPPRESS_BROWSER_REFRESH=1
- Dominant language
- C#
- Stars
- 3.2k
- Forks
- 1.3k
- PR merge metrics
- PR metrics pending
Description
## Description
When running `dotnet watch` on a Blazor Web App with WebAssembly interactivity (or any Blazor-hosted project) with the environment variable `DOTNET_WATCH_SUPPRESS_BROWSER_REFRESH=1` set, the process builds successfully but exits immediately (exit code 0) without ever starting the application server.
## Expected behavior
`dotnet watch` should start the server and enable hot reload for server-side .NET code, just without the browser-refresh middleware. The documentation states this variable causes dotnet watch to "not refresh browsers when it detects file changes" - it should not prevent the server from starting entirely.
## Actual behavior
After a successful build, `dotnet watch` outputs:
```
dotnet watch ⌚ Application kind: BlazorHosted. '...' references BlazorWebAssembly project '...'.
dotnet watch ⌚ [ReproApp (net10.0)] Skipping configuring browser-refresh middleware since its refresh server suppressed via environment variable DOTNET_WATCH_SUPPRESS_BROWSER_REFRESH.
dotnet watch ⌚ Terminating remaining child processes.
```
And exits with code 0, never starting the server.
## Steps to reproduce
```bash
# 1. Create a new Blazor Web App with WebAssembly interactivity in /tmp
cd /tmp
dotnet new blazor -int WebAssembly -o ReproApp
# 2. Set the environment variable
export DOTNET_WATCH_SUPPRESS_BROWSER_REFRESH=1
# 3. Run dotnet watch
cd ReproApp/ReproApp
dotnet watch --verbose
# 4. Observe: build succeeds, but server never starts - process exits immediately
```
## Environment
```
.NET SDK: 10.0.102
Runtime: 10.0.2
OS: Ubuntu 24.04 (Linux x64)
```
## Verbose output
```
dotnet watch ⌚ Working directory: '/tmp/dotnet-watch-bug-repro/ReproApp/ReproApp'
dotnet watch ⌚ Watching with Hot Reload.
dotnet watch ⌚ Polling file watcher is enabled
dotnet watch 🔥 Hot reload enabled. For a list of supported edits, see https://aka.ms/dotnet/hot-reload.
dotnet watch 💡 Press Ctrl+R to restart.
dotnet watch 🔨 Building /tmp/dotnet-watch-bug-repro/ReproApp/ReproApp/ReproApp.csproj ...
dotnet watch 🚀 Launched '/usr/share/dotnet/dotnet' with arguments 'build ...': process id 27283
dotnet watch ⌚ Process id 27283 ran for 8584ms and exited with exit code 0.
dotnet watch 🔨 Build succeeded: /tmp/dotnet-watch-bug-repro/ReproApp/ReproApp/ReproApp.csproj
...
dotnet watch ⌚ Watching 73 file(s) for changes
dotnet watch ⌚ Application kind: BlazorHosted. '/tmp/dotnet-watch-bug-repro/ReproApp/ReproApp/ReproApp.csproj' references BlazorWebAssembly project '/tmp/dotnet-watch-bug-repro/ReproApp/ReproApp.Client/ReproApp.Client.csproj'.
dotnet watch ⌚ [ReproApp (net10.0)] Skipping configuring browser-refresh middleware since its refresh server suppressed via environment variable DOTNET_WATCH_SUPPRESS_BROWSER_REFRESH.
dotnet watch ⌚ Terminating remaining child processes.
```
## Related issues
- #44251 - `dotnet watch` hard exits when it cannot launch browser
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.