Skip to content

dotnet watch on the AppHost regularly breaks with a Blazor WASM project #48898

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
1 task done
Hona opened this issue May 12, 2025 · 1 comment · May be fixed by #48909
Open
1 task done

dotnet watch on the AppHost regularly breaks with a Blazor WASM project #48898

Hona opened this issue May 12, 2025 · 1 comment · May be fixed by #48909
Labels
Aspire untriaged Request triage from a team member

Comments

@Hona
Copy link

Hona commented May 12, 2025

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I have a simple aspnetcore backend and blazor wasm standalone frontend setup with aspire.

AppHost Program.cs

var builder = DistributedApplication.CreateBuilder(args);

var api = builder.AddProject<Projects.Debtware_Client_Portal_Api>("api");

var ui = builder.AddProject<Projects.Debtware_Client_Portal>("ui").WithReference(api).WaitFor(api);

builder.Build().Run();

I am running the whole application using dotnet watch on Aspire AppHost project.

dotnet watch startup output

PS [REDACTED_PATH]> dotnet watch --property WarningLevel=0
dotnet watch 🔥 Hot reload enabled. For a list of supported edits, see https://aka.ms/dotnet/hot-reload.
💡 Press "Ctrl + R" to restart.
dotnet watch ⌚ Building [REDACTED_PATH]\Revive.AppHost.csproj ...
dotnet watch 🔨 Build succeeded: [REDACTED_PATH]\Revive.AppHost.csproj
Using launch settings from [REDACTED_PATH]\Properties\launchSettings.json...
info: Aspire.Hosting.DistributedApplication[0]
Aspire version: 9.2.0+0fcb1e9885266c1700c49c16513a6d97480bb058
info: Aspire.Hosting.DistributedApplication[0]
Distributed application starting.
info: Aspire.Hosting.DistributedApplication[0]
Application host directory is: [REDACTED_PATH]
info: Aspire.Hosting.DistributedApplication[0]
Now listening on: https://localhost:17243
info: Aspire.Hosting.DistributedApplication[0]
Login to the dashboard at https://localhost:17243/login?t=78a9e160d0643e70a21fc9a73be7c4cc
info: Aspire.Hosting.DistributedApplication[0]
Distributed application started. Press Ctrl+C to shut down.
Using launch settings from [REDACTED_PATH]\Properties\launchSettings.json...
info: Microsoft.Hosting.Lifetime[14]
Now listening on: https://localhost:54175
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0]
Content root path: [REDACTED_PATH]

However, when making standard hot reload changes to the WASM project (not dirty, or dirty), then the change succeeds, and follows up immediately crashing the whole program.

See the output & stacktrace here

dotnet watch ⌚ File updated: [REDACTED_PATH]\IACustomerPackSection.razor
dotnet watch 🔥 [Debtware.Client.Portal.Api (net9.0)] Hot reload succeeded.
dotnet watch 🔥 [Debtware.Client.Portal (net9.0)] Hot reload succeeded.
dotnet watch ❌ [Debtware.Client.Portal.Api (net9.0)] Exited with error code -1
dotnet watch ❌ [Debtware.Client.Portal (net9.0)] Exited with error code -1
dotnet watch ❌ [Revive.AppHost (net9.0)] Exited with error code -1
dotnet watch ❌ System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.DotNet.Watch.BlazorWebAssemblyDeltaApplier.Apply(ImmutableArray`1 updates, CancellationToken cancellationToken)
   at Microsoft.DotNet.Watch.BlazorWebAssemblyHostedDeltaApplier.Apply(ImmutableArray`1 updates, CancellationToken cancellationToken)
   at Microsoft.DotNet.Watch.CompilationHandler.<>c__DisplayClass20_0.<<HandleFileChangesAsync>b__2>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.DotNet.Watch.CompilationHandler.HandleFileChangesAsync(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

Expected Behavior

The hot reload succeeds without crashing the entire apphost process.

Steps To Reproduce

I got an even earlier error while setting up a minimal repro.

I created this project https://github.com/Hona/AspireWasmCrash
Then - dotnet run on the host starts fine and the UI is responsive.
Then - dotnet watch on the host errors immediately.

Here is the output of both combined.

run vs watch output

PS C:\Repos\AspireWasmCrash\AspireWasmCrash> dotnet watch --property WarningLevel=0

dotnet watch 🔥 Hot reload enabled. For a list of supported edits, see https://aka.ms/dotnet/hot-reload.
💡 Press "Ctrl + R" to restart.
dotnet watch ⌚ Building C:\Repos\AspireWasmCrash\AspireWasmCrash\AspireWasmCrash.csproj ...
dotnet watch 🔨 Build succeeded: C:\Repos\AspireWasmCrash\AspireWasmCrash\AspireWasmCrash.csproj
dotnet watch ❌ [AspireWasmCrash (net9.0)] Exited with error code -1
dotnet watch ❌ System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.DotNet.Watch.BlazorWebAssemblyDeltaApplier.WaitForProcessRunningAsync(CancellationToken cancellationToken)
at Microsoft.DotNet.Watch.RunningProject.WaitForProcessRunningAsync(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
PS C:\Repos\AspireWasmCrash\AspireWasmCrash> dotnet run
Using launch settings from C:\Repos\AspireWasmCrash\AspireWasmCrash\Properties\launchSettings.json...
Building...
info: Aspire.Hosting.DistributedApplication[0]
Aspire version: 9.0.0+01ed51919f8df692ececce51048a140615dc759d
info: Aspire.Hosting.DistributedApplication[0]
Distributed application starting.
info: Aspire.Hosting.DistributedApplication[0]
Application host directory is: C:\Repos\AspireWasmCrash\AspireWasmCrash
info: Aspire.Hosting.DistributedApplication[0]
Now listening on: https://localhost:17078
info: Aspire.Hosting.DistributedApplication[0]
Login to the dashboard at https://localhost:17078/login?t=d86d6d466f55d44a04ccffb4fedee39e
info: Aspire.Hosting.DistributedApplication[0]
Distributed application started. Press Ctrl+C to shut down.

Exceptions (if any)

No response

.NET Version info

PS C:\Repos\Revive2\src\Hosting\Revive.AppHost> dotnet --info
.NET SDK:
 Version:           9.0.203
 Commit:            dc7acfa194
 Workload version:  9.0.200-manifests.1e5233e8
 MSBuild version:   17.13.20+a4ef1e90f

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22631
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Program Files\dotnet\sdk\9.0.203\

.NET workloads installed:
 [aspire]
   Installation Source: SDK 9.0.200, VS 17.13.35806.99
   Manifest Version:    8.2.2/8.0.100
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.aspire\8.2.2\WorkloadManifest.json
   Install Type:              Msi

 [wasm-tools]
   Installation Source: SDK 9.0.200
   Manifest Version:    9.0.4/9.0.100
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.workload.mono.toolchain.current\9.0.4\WorkloadManifest.json
   Install Type:              Msi

Configured to use loose manifests when installing new manifests.

Host:
  Version:      9.0.4
  Architecture: x64
  Commit:       f57e6dc747

.NET SDKs installed:
  8.0.311 [C:\Program Files\dotnet\sdk]
  8.0.408 [C:\Program Files\dotnet\sdk]
  9.0.105 [C:\Program Files\dotnet\sdk]
  9.0.200 [C:\Program Files\dotnet\sdk]
  9.0.203 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 8.0.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 9.0.2 [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 3.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 9.0.2 [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 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 8.0.13 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 8.0.15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 9.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 9.0.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  x86   [C:\Program Files (x86)\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
  Not set

global.json file:
  C:\Repos\Revive2\global.json

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

Anything else?

No response

@davidfowl davidfowl transferred this issue from dotnet/aspire May 12, 2025
@dotnet-policy-service dotnet-policy-service bot added the untriaged Request triage from a team member label May 12, 2025
@davidfowl
Copy link
Member

@tmat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Aspire untriaged Request triage from a team member
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants