Skip to content

Detect Blazor WebAssembly apps without inspectUri#9507

Open
javiercn wants to merge 3 commits into
dotnet:mainfrom
javiercn:blazor-wasm-static-detection
Open

Detect Blazor WebAssembly apps without inspectUri#9507
javiercn wants to merge 3 commits into
dotnet:mainfrom
javiercn:blazor-wasm-static-detection

Conversation

@javiercn

@javiercn javiercn commented Jul 7, 2026

Copy link
Copy Markdown
Member

Problem

The .NET 11 templates no longer emit inspectUri in launchSettings.json (for both standalone Blazor WebAssembly and Blazor Web App WebAssembly host projects). The extension detected Blazor WebAssembly apps by reading inspectUri from launchSettings.json (src/shared/utils.ts), so detection now fails: the blazorwasm debug configuration is never selected, the browser JS debugger / ws-proxy is not attached, and .razor breakpoints are not hit.

Fixes the extension side of dotnet/aspnetcore#67507.

Where the check runs (host vs. WASM project)

For hosted apps the debug launch (and thus detection) runs on the server/host project, which has no WebAssembly SDK marker of its own. inspectUri in the host''s launchSettings.json was the only signal. For standalone, the single project is the WebAssembly-SDK project itself.

Change (additive)

The existing checks are kept intact and the newer heuristics are layered on top (opt-in / additive), so older projects keep working exactly as before:

  • isBlazorWebAssemblyProject keeps the original inspectUri check and additionally recognizes an enableWebAssemblyDebugging launch profile flag. This is the escape hatch: it unconditionally signals the need for WebAssembly debugging for non-standard layouts. It is matched with indexOf (not JSON.parse) because launchSettings.json may contain comments. Templates do not set it by default.
  • New isBlazorWebAssemblyHostedServer: recognizes a hosted host as an executable Microsoft.NET.Sdk.Web project that references Microsoft.AspNetCore.Components.WebAssembly.Server (the package that provides the WebAssembly debugging middleware). OR-ed with the original isBlazorWebAssemblyHosted heuristic at the call sites.
  • Standalone additionally recognizes Microsoft.NET.Sdk.BlazorWebAssembly SDK projects (already surfaced by isWebProject), OR-ed with the original signal. A hosted project is never standalone.

The original isBlazorWebAssemblyHosted (including its targetsDotnetCore guard) is unchanged.

The runtime inspectUri handling in blazorDebugConfigurationProvider.ts is intentionally left as-is: it already defaults the ws-proxy URL when inspectUri is absent, so debugging works once the blazorwasm config type is selected.

Testing

  • New unit tests in test/omnisharp/omnisharpUnitTests/blazorWebAssemblyDetection.test.ts covering the original inspectUri path, the enableWebAssemblyDebugging escape hatch (including commented JSON), the WebAssembly.Server host heuristic, and the WebAssembly SDK signal.
  • tsc --noEmit, eslint, existing assets.test.ts (48 tests), and the new tests all pass.

The .NET templates no longer emit inspectUri in launchSettings.json, which
broke detection of Blazor WebAssembly apps and prevented .razor breakpoints
from being hit when debugging (dotnet/aspnetcore#67507).

Replace the inspectUri read with static, project-based signals:
- Standalone: the Microsoft.NET.Sdk.BlazorWebAssembly SDK project.
- Hosted: an executable Web SDK host referencing the
  Microsoft.AspNetCore.Components.WebAssembly.Server package.

Add an 'enableWebAssemblyDebugging' launchSettings.json profile escape hatch
that unconditionally forces WebAssembly debugging for non-standard layouts.
Templates do not set it by default.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 7, 2026 12:59
@javiercn javiercn requested a review from a team as a code owner July 7, 2026 12:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates Blazor WebAssembly debug configuration selection to no longer depend on inspectUri in launchSettings.json (which is no longer emitted by newer .NET templates). Instead, it uses static project signals (SDK type + hosted server package reference) plus a enableWebAssemblyDebugging: true launch profile escape hatch, so the extension can still pick the correct blazorwasm debug configuration.

Changes:

  • Replace inspectUri-based detection with getBlazorWebAssemblyDebugInfo using project SDK markers and a hosted-server package reference check.
  • Add enableWebAssemblyDebugging launch profile escape hatch support and unit tests for detection behavior.
  • Wire the new detection into both OmniSharp and Roslyn workspace debug info providers and document the change in the changelog.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/omnisharp/omnisharpUnitTests/blazorWebAssemblyDetection.test.ts Adds unit coverage for hosted/standalone detection and the escape hatch behavior.
src/shared/utils.ts Implements new static Blazor WASM detection helpers and the launchSettings escape hatch reader.
src/omnisharp/utils.ts Switches OmniSharp workspace info enrichment to the new detection API.
src/lsptoolshost/debugger/roslynWorkspaceDebugConfigurationProvider.ts Switches Roslyn workspace debug info enrichment to the new detection API.
CHANGELOG.md Notes the detection change and escape hatch for the next prerelease line.

Comment thread src/shared/utils.ts Outdated
Keep the original inspectUri check and isBlazorWebAssemblyHosted logic intact
and layer the newer heuristics on top instead of replacing them:
- isBlazorWebAssemblyProject also recognizes the enableWebAssemblyDebugging
  launch profile escape hatch (matched with indexOf so commented
  launchSettings.json still works).
- Add isBlazorWebAssemblyHostedServer for the WebAssembly.Server package
  signal, OR-ed with the original hosted heuristic at the call sites.
- Standalone additionally recognizes WebAssembly SDK projects.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@thaystg

thaystg commented Jul 7, 2026

Copy link
Copy Markdown
Member

LGTM

Comment thread CHANGELOG.md Outdated
Comment thread src/shared/utils.ts Outdated
Per reviewer guidance, detect the launchSettings signals with the existing
jsonc-parser instead of raw text matching. This tolerates comments/trailing
commas, avoids false positives from commented-out properties, and checks the
actual boolean value of the enableWebAssemblyDebugging escape hatch.

Also remove the CHANGELOG.md entry: 2.151 has shipped and the 2.152 release
notes are generated automatically from PRs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 7, 2026 17:10
@javiercn

javiercn commented Jul 7, 2026

Copy link
Copy Markdown
Member Author

Thanks for the review! Addressed in d3136cf:

  • jsonc-parser (@gregg-miskelly / @copilot-pull-request-reviewer): isBlazorWebAssemblyProject now parses launchSettings.json with jsonc-parser instead of raw text matching. It iterates profiles and checks inspectUri presence or enableWebAssemblyDebugging === true. This tolerates comments/trailing commas, ignores commented-out properties, and respects the actual boolean value. Added tests for the commented-out and false-value cases.
  • CHANGELOG (@gregg-miskelly): removed the entry since 2.151 has shipped and 2.152 notes are generated from PRs.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

@javiercn

javiercn commented Jul 7, 2026

Copy link
Copy Markdown
Member Author

🆙 📅

@javiercn

javiercn commented Jul 8, 2026

Copy link
Copy Markdown
Member Author

@gregg-miskelly is there anything else we need to do to get this merged? (never worked on this repo)

/cc: @thaystg

@gregg-miskelly

Copy link
Copy Markdown
Contributor

LGTM. @javiercn should I hit the merge button?

@javiercn

javiercn commented Jul 8, 2026

Copy link
Copy Markdown
Member Author

@gregg-miskelly Yes please.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants