Blazor Hosting Integration: BrowserDebuggerResource and debug commands
- Dominant language
- C#
- Stars
- 6.3k
- Forks
- 991
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 196
Description
## Summary
Implement the hosting-side support for Blazor WebAssembly debugging in Aspire. This models the debugger as a resource and exposes debug commands on the dashboard.
Parent epic: https://github.com/dotnet/aspire/issues/17795
## Work Items
- [ ] Finalize `BrowserDebuggerResource` and `BrowserLaunchConfiguration` types.
- [ ] Implement `BrowserDebuggerHelper.AddBrowserDebuggerResource` with command registration and state machine.
- [ ] Implement automatic WASM client project detection for hosted scenarios.
- [ ] Register debug commands for standalone WASM apps (gateway path).
- [ ] Register debug commands for hosted Blazor apps.
- [ ] Ensure the debugger resource is hidden from the dashboard resource list.
- [ ] Ensure debug commands are disabled when the parent resource is not Running.
## Design
A hidden `BrowserDebuggerResource` (`ExecutableResource` subclass) is created as a child of the endpoint-bearing parent with `WithExplicitStart()`, so it only launches when the user invokes debugging.
Two mutually-exclusive commands on the command target:
- **Debug in Browser** - visible when no session is active and the parent is Running.
- **Stop Browser Debug** - visible only when a session is active.
A state machine watcher subscribes to `ResourceNotificationService.WatchAsync()` and monitors the debugger resource for terminal states. On detection, it resets the active flag and publishes an update to toggle command visibility.
For hosted scenarios, the client project is resolved from the server's `ProjectReference` elements (looks for `Microsoft.NET.Sdk.BlazorWebAssembly`).
Contributor guide
Assessment
This issue has not been assessed yet.