-
Notifications
You must be signed in to change notification settings - Fork 760
Add projectPath and launchBrowser options to blazorwasm debug configuration #9427
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
LittleLittleCloud
wants to merge
2
commits into
dotnet:main
Choose a base branch
from
LittleLittleCloud:u/xiaoyun/blazorwasmDebug
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+147
−7
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| # Blazor WebAssembly Browser Debug Control | ||
|
|
||
| ## Summary | ||
|
|
||
| Expose the project path directly on the existing `blazorwasm` debug configuration so callers can launch browser and WebAssembly debugging for an already-running app without composing low-level debug adapter configurations. Also allow `blazorwasm` launch configurations to start only the app process by disabling browser launch. | ||
|
|
||
| The motivating integration is the Aspire browser launch command described in [Aspire Extension: Browser and WASM debug session support](https://github.com/microsoft/aspire/issues/17797). Aspire can receive a browser launch request for an already-running app and needs VS Code to start browser JavaScript debugging plus Blazor WebAssembly managed debugging. The Aspire extension should be able to invoke the existing high-level `blazorwasm` debug type instead of composing js-debug, `monovsdbg_wasm`, VSDbg bridge ports, and cascade termination behavior itself. | ||
|
|
||
| ## Current Behavior | ||
|
|
||
| The existing `BlazorDebugConfigurationProvider` owns the detailed Blazor orchestration: | ||
|
|
||
| - launch the app for `request: "launch"`; | ||
| - read `launchSettings.json` for `inspectUri` and `applicationUrl`; | ||
| - launch Edge or Chrome through js-debug; | ||
| - optionally start the VSDbg WebAssembly bridge for supported .NET 9+ projects; | ||
| - track sibling sessions so terminating one Blazor session terminates the rest. | ||
|
|
||
| Today `launchBrowser` calls `useVSDbg` with a value derived from `cwd`. That is incorrect for callers such as Aspire, where the browser launch command can provide the `.csproj` path independently from the web root or working directory. Target framework detection should use a project path, not the launch working directory. | ||
|
|
||
| ## Proposed Schema | ||
|
|
||
| Add `projectPath` to `blazorwasm` attach configurations: | ||
|
|
||
| ```jsonc | ||
| { | ||
| "name": "C#: Launch Blazor Browser Only", | ||
| "type": "blazorwasm", | ||
| "request": "attach", | ||
| "projectPath": "${workspaceFolder}/Client/Client.csproj", | ||
| "url": "https://localhost:5001", | ||
| "browser": "edge" | ||
| } | ||
| ``` | ||
|
|
||
| The existing request semantics already cover the key modes: | ||
|
|
||
| - `request: "launch"`: start the app and browser/WASM debugging by default. | ||
| - `request: "attach"`: start browser/WASM debugging only against an already-running app. | ||
|
|
||
| For app-only scenarios, callers can use `request: "launch"` with browser launch disabled: | ||
|
|
||
| ```jsonc | ||
| { | ||
| "name": "C#: Launch both app and browser", | ||
| "type": "blazorwasm", | ||
| "request": "launch", | ||
| "projectPath": "${workspaceFolder}/Client/Client.csproj", | ||
| "browser": "edge", | ||
| "launchBrowser": true | ||
| } | ||
|
|
||
| { | ||
| "name": "C#: Launch Blazor App Only", | ||
| "type": "blazorwasm", | ||
| "request": "launch", | ||
| "projectPath": "${workspaceFolder}/Client/Client.csproj", | ||
| "url": "https://localhost:5001", | ||
| "launchBrowser": false | ||
| } | ||
|
|
||
| { | ||
| "name": "C#: Attach debugging browser", | ||
| "type": "blazorwasm", | ||
| "request": "attach", | ||
| "projectPath": "${workspaceFolder}/Client/Client.csproj", | ||
| "url": "https://localhost:5001", | ||
| "browser": "edge" | ||
| } | ||
| ``` | ||
|
|
||
| ## Aspire Mapping | ||
|
|
||
| Aspire browser launch data should map into the existing `blazorwasm` surface: | ||
|
|
||
| - DCP `url` maps to `url`. | ||
| - DCP project path maps to `projectPath` when it identifies a `.csproj`. | ||
| - DCP `web_root` maps to `webRoot` when it identifies a static web root. | ||
| - Browser selection maps to `browser`. | ||
| - Browser isolation flags should remain owned by the browser launcher path and should not require Aspire to know C# adapter internals. | ||
|
|
||
| ## Implementation Notes | ||
|
|
||
| `BlazorDebugConfigurationProvider.launchBrowser` should resolve `configuration.projectPath` and pass that value to `useVSDbg`. It may fall back to `cwd` for compatibility with existing launch configurations, but `cwd` should no longer be the primary input for target framework detection. | ||
|
|
||
| `useVSDbg` already accepts either a `.csproj` file path or a directory, because `findCsprojFiles` handles both forms. Passing the actual project path fixes .NET 9+ detection for integrations where `cwd` is not the project file or project directory. | ||
|
|
||
| `BlazorDebugConfigurationProvider.resolveDebugConfiguration` should skip `launchBrowser` when `configuration.launchBrowser === false`. This keeps the existing launch path but allows callers to use `blazorwasm` for app-only launch when they intentionally do not want browser or WASM debug sessions. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm guessing this wasn't intended to be committed, but if it was, perhaps as a readme.md in the blazorDebug folder might be better?