Skip to content

Skip _ResolveBlazorWasmOutputs for .NET 11+ and move BlazorRoutingEnableRegexConstraint to SDK#53602

Open
javiercn wants to merge 3 commits intomainfrom
javiercn/cleanup-wasm-packaging
Open

Skip _ResolveBlazorWasmOutputs for .NET 11+ and move BlazorRoutingEnableRegexConstraint to SDK#53602
javiercn wants to merge 3 commits intomainfrom
javiercn/cleanup-wasm-packaging

Conversation

@javiercn
Copy link
Member

@javiercn javiercn commented Mar 26, 2026

Summary

Updates the Blazor WebAssembly SDK to:

  1. Skip the legacy _ResolveBlazorWasmOutputs target for .NET 11+ (framework assets handle blazor.webassembly.js)
  2. Own the BlazorRoutingEnableRegexConstraint feature (moved from the package props file)

Changes

Microsoft.NET.Sdk.BlazorWebAssembly.Current.props

  • Added BlazorRoutingEnableRegexConstraint property default (false) — previously shipped in the Microsoft.AspNetCore.Components.WebAssembly package props

Microsoft.NET.Sdk.BlazorWebAssembly.6_0.targets

  • Added _TargetingNET110OrLater version check property
  • Conditioned _ResolveBlazorWasmOutputs with Condition="'$(_TargetingNET110OrLater)' != 'true'" so it only runs for .NET 10 and earlier
  • Added RuntimeHostConfigurationOption item for Microsoft.AspNetCore.Components.Routing.RegexConstraintSupport — flows the BlazorRoutingEnableRegexConstraint value to runtimeconfig.json configProperties, which the Mono WASM runtime reads and applies as an AppContext switch

How it works

For .NET 11+: The Microsoft.AspNetCore.Components.WebAssembly package now uses the SWA Framework Assets system. blazor.webassembly.js is declared with SourceType=Framework in the package props and automatically materialized by UpdateExistingPackageStaticWebAssets. No custom detection via BlazorWebAssemblyJSPath is needed.

For .NET 10 and earlier: _ResolveBlazorWasmOutputs continues to run as before, reading BlazorWebAssemblyJSPath from the package props file for backward compatibility.

Regex constraint support: The RuntimeHostConfigurationOption flows BlazorRoutingEnableRegexConstraint to runtimeconfig.json. The Mono WASM runtime reads configProperties and passes them to mono_wasm_load_runtime as AppContext key-value pairs, so AppContext.TryGetSwitch() works natively. The old AssemblyMetadataAttribute workaround in the aspnetcore repo has been removed.

Companion PR

Testing

  • .NET 11 Blazor WASM app: builds and runs with framework assets (no _ResolveBlazorWasmOutputs)
  • .NET 10 Blazor WASM app: builds with backward-compatible BlazorWebAssemblyJSPath flow

For .NET 11+, blazor.webassembly.js is provided as a Framework static web
asset from the Microsoft.AspNetCore.Components.WebAssembly package and is
automatically materialized by UpdateExistingPackageStaticWebAssets. The
legacy _ResolveBlazorWasmOutputs target (which reads BlazorWebAssemblyJSPath)
is no longer needed.

For .NET 10 and earlier, the target continues to run as before for backward
compatibility.
@github-actions github-actions bot added the Area-AspNetCore RazorSDK, BlazorWebAssemblySDK, StaticWebAssetsSDK label Mar 26, 2026
@dotnet-policy-service
Copy link
Contributor

Thanks for your PR, @@javiercn.
To learn about the PR process and branching schedule of this repo, please take a look at the SDK PR Guide.

@javiercn javiercn marked this pull request as ready for review March 26, 2026 07:23
@javiercn javiercn requested a review from a team as a code owner March 26, 2026 07:23
Copilot AI review requested due to automatic review settings March 26, 2026 07:23
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the Blazor WebAssembly SDK targets to stop running the legacy _ResolveBlazorWasmOutputs target for .NET 11+ builds, relying instead on Static Web Assets “Framework” assets to provide blazor.webassembly.js.

Changes:

  • Added an MSBuild property _TargetingNET110OrLater based on TargetFrameworkVersion.
  • Added a condition to _ResolveBlazorWasmOutputs so it only runs for .NET 10 and earlier (per the PR intent).
  • Added explanatory comments describing the new behavior split.

javiercn and others added 2 commits March 26, 2026 10:42
…6_0.targets

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
The regex constraint runtime switch was previously shipped in the
Microsoft.AspNetCore.Components.WebAssembly package props file. Now that
the Mono WASM runtime reads configProperties from runtimeconfig.json,
the switch flows natively via RuntimeHostConfigurationOption.

- Add BlazorRoutingEnableRegexConstraint default (false) to SDK props
- Add RuntimeHostConfigurationOption item to SDK targets
@javiercn javiercn changed the title Skip _ResolveBlazorWasmOutputs for .NET 11+ (Framework Assets) Skip _ResolveBlazorWasmOutputs for .NET 11+ and move BlazorRoutingEnableRegexConstraint to SDK Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-AspNetCore RazorSDK, BlazorWebAssemblySDK, StaticWebAssetsSDK

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants