Description
Description
We have a solution with Aspire which worked well with dotnet watch
command until net9 (net8 never thrown exception).
Today after some attempts on try to reproduce with less projects as possibile we discovered that the exception was thrown if the Aspire project has at least one reference to a Blazor project.
Blazor project is a hosted wasm model so the referenced project is the "WebServer (aspnetcore)" and not directly the "Web (blazor wasm)".
System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.DotNet.Watch.BlazorWebAssemblyDeltaApplier.ApplyManagedCodeUpdates(ImmutableArray`1 updates, CancellationToken cancellationToken)
at Microsoft.DotNet.Watch.BlazorWebAssemblyHostedDeltaApplier.ApplyManagedCodeUpdates(ImmutableArray`1 updates, CancellationToken cancellationToken)
at Microsoft.DotNet.Watch.CompilationHandler.<>c__DisplayClass19_0.<<HandleManagedCodeChangesAsync>b__2>d.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.DotNet.Watch.CompilationHandler.HandleManagedCodeChangesAsync(Func`3 restartPrompt, CancellationToken cancellationToken)
at Microsoft.DotNet.Watch.HotReloadDotNetWatcher.WatchAsync(CancellationToken shutdownCancellationToken)
at Microsoft.DotNet.Watch.HotReloadDotNetWatcher.WatchAsync(CancellationToken shutdownCancellationToken)
at Microsoft.DotNet.Watch.HotReloadDotNetWatcher.WatchAsync(CancellationToken shutdownCancellationToken)
at Microsoft.DotNet.Watch.Program.RunAsync()
dotnet watch ❌ An unexpected error occurred
Reproduction Steps
- Solution with Aspire host, some references to services (aspnetcore) and a blazor-hosted-wasm project
- Run
dotnet watch
from aspire host project - Made a change in one random file
- See hotreload logs in console (some services write hot reload success) and then the exception
Expected behavior
Work without errors
Actual behavior
After made a change on any file of any project the command throw exception
Regression?
No response
Known Workarounds
If we remove the reference to the blazor project the command works like a charm.
So for now we launch aspire with watch and blazor projects with watch as well but each into separated VS or terminal..
Configuration
.NET SDK:
Version: 9.0.300-preview.0.25177.5
Commit: 3d5b396
Workload version: 9.0.300-manifests.78a0f7ac
MSBuild version: 17.14.0-preview-25175-08+5880e1c75
Runtime Environment:
OS Name: Windows
OS Version: 10.0.26100
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\9.0.300-preview.0.25177.5\
.NET workloads installed:
There are no installed workloads to display.
Configured to use loose manifests when installing new manifests.
Host:
Version: 9.0.4
Architecture: x64
Commit: f57e6dc747
.NET SDKs installed:
9.0.203 [C:\Program Files\dotnet\sdk]
9.0.300-preview.0.25177.5 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 8.0.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 8.0.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 8.0.14 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 9.0.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 9.0.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Other information
No response