Skip to content

[release/11.0.1xx] Backport #56118: Unify dotnet watch browser tools activation and forwarding - #56362

Merged
javiercn merged 4 commits into
release/11.0.1xxfrom
javiercn-browser-tools-backport-11-0
Sep 21, 2026
Merged

javiercn merged 4 commits into
release/11.0.1xxfrom
javiercn-browser-tools-backport-11-0

Conversation

@javiercn

Copy link
Copy Markdown
Member

Backport of #56118 to release/11.0.1xx.

This is a manual backport because automatic /backport workflow run 35606166997 failed without creating a pull request.

Description

Unifies dotnet watch browser tools behind the application-origin provider contract from #56118. The application build owns the browser-tools RSA key pair and emits build-only, non-published client assets. ASP.NET Core applications forward browser traffic to the loopback dotnet watch provider, while standalone Blazor WebAssembly uses the development Gateway route.

This also removes legacy response rewriting/provider-served scripts, preserves origin validation and additional-origin configuration, supports ordered replay and multiple browser windows, reports browser update failures accurately, and keeps browser-tools assets out of publish output.

Conflict resolution

  • Preserved the release branch's prior deletion of .github/memory/{ARCHITECTURE,FILE_MAP,KNOWN_ISSUES}.md.
  • Kept Unify dotnet watch browser tools activation and forwarding #56118's intended deletion of the legacy BlazorWasmHotReloadMiddleware, BrowserRefreshMiddleware, and their tests despite release-line edits to those files.
  • Took the provider-based HostingStartupTest from Unify dotnet watch browser tools activation and forwarding #56118 in full, replacing tests for the removed legacy endpoints.
  • Applied the complete duplicate-compression baseline update under the release branch's existing Build_DoesNotFailToCompress_TwoAssetsWith_TheSameContent filename; main had already renamed that baseline to DoesNotFailToCompress_TwoAssetsWith_TheSameContent.
  • Retained release-specific Hot Reload API and compression-test shapes that predate later main refactors.

Validation

  • Full build.cmd redist build — 0 warnings, 0 errors
  • dotnet-watch.Tests: browser tools build outputs, endpoint router, and refresh server — 36 passed
  • Microsoft.AspNetCore.Watch.BrowserRefresh.Tests: forwarder, TagHelper activation, and hosting startup — 15 passed
  • Microsoft.Extensions.DotNetDeltaApplier.Tests: provider router, replay, and WebAssembly client — 26 passed
  • Microsoft.NET.Build.Tests: evaluator fast-path tests — 3 passed
  • Static Web Assets BaselineTest category — running
  • Blazor WebAssembly BaselineTest category — pending

Note

This PR description was drafted with GitHub Copilot.

javiercn and others added 2 commits September 21, 2026 15:51
#56118)

This change unifies `dotnet watch` browser tools behind a single application-origin provider contract.

The application build now owns the browser-tools RSA key pair and emits build-only, non-published browser assets containing the client and pinned public key. Browsers connect through the application’s origin to a loopback `dotnet watch` provider, using an RSA-OAEP-encrypted browser-generated secret for authentication. ASP.NET Core applications use a lightweight forwarding middleware, while standalone Blazor WebAssembly uses the development Gateway/YARP route.
The change also:
- Supports Blazor WebAssembly, Blazor Web SSR/Interactive WebAssembly, Razor Pages, and other web applications across supported target frameworks.
- Removes legacy response rewriting and provider-served executable scripts.
- Preserves origin validation and explicit additional-origin configuration.
- Provides ordered replay for browsers connecting after updates and parallel delivery to multiple browser windows.
- Reports browser update failures accurately instead of presenting unsuccessful changes as applied.
- Loads the current build-generated private key when each browser connects, allowing ordinary `dotnet run` build behavior and clean key rotation.
- Consolidates WebAssembly activation and Hot Reload agent initialization into one initializer.
- Keeps all browser-tools assets out of publish output.
- Updates Static Web Assets and WebAssembly baselines for the new build-only assets.

Validation included a Playwright matrix for .NET 10 and .NET 11 covering standalone Blazor WebAssembly, Blazor Web SSR, Blazor Web with Interactive WebAssembly, and Razor Pages. Managed/Razor updates, CSS updates, authenticated connections, multiple-tab replay/reconnect, and ordinary `dotnet run` behavior all passed.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Keep the release/11.0.1xx baseline filename while applying the complete baseline content from the merged source PR.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings September 21, 2026 14:07
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).
1 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

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.

Copilot review overview

🟡 Changes recommended

Moderate issues remain in update reporting, routing, key validation, WebAssembly initialization, and baselines.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Medium severity · 1 Low severity

Open (2)
What changed in this PR

This backport unifies dotnet watch browser tools around build-generated assets, authenticated provider forwarding, replay, and WebAssembly/server activation.

Changes:

  • Adds build-owned browser assets and RSA key management.
  • Replaces legacy middleware with application-origin forwarding.
  • Updates Hot Reload behavior, tests, baselines, and signing configuration.

Review findings remain around update failure reporting, origin and path-base routing, endpoint handling, key validation, WebAssembly initialization, documentation, and baselines.

File Review summary
test/​Microsoft.NET.Sdk.StaticWebAssets.Tests/​StaticWebAssetsIntegrationTest.cs Updates rebuild manifest coverage.
test/​Microsoft.NET.Sdk.StaticWebAssets.Tests/​StaticWebAssetsBaselines/​Rebuild_RegeneratesJsonManifestAndCopiesItToOutputFolder_Rebuild.Build.files.json Updates build baseline.
test/​Microsoft.NET.Sdk.StaticWebAssets.Tests/​StaticWebAssetsBaselines/​PublishWorks_With_PrecompressedAssets.Build.files.json Updates publish baseline.
test/​Microsoft.NET.Sdk.StaticWebAssets.Tests/​StaticWebAssetsBaselines/​BuildProjectWithReferences_WorksWithStaticWebAssetsV1ClassLibraries.Build.files.json Updates referenced-project baseline.
test/​Microsoft.NET.Sdk.StaticWebAssets.Tests/​StaticWebAssetsBaselines/​BuildProjectWithReferences_NoDependencies_GeneratesJsonManifestAndCopiesItToOutputFolder_NoDependencies.Build.files.json Updates no-dependencies baseline.
test/​Microsoft.NET.Sdk.StaticWebAssets.Tests/​StaticWebAssetsBaselines/​BuildProjectWithReferences_IncorporatesInitializersFromClassLibraries.Build.files.json Updates initializer baseline.
test/​Microsoft.NET.Sdk.StaticWebAssets.Tests/​StaticWebAssetsBaselines/​BuildProjectWithReferences_GeneratesJsonManifestAndCopiesItToOutputFolder.Build.files.json Updates manifest baseline.
test/​Microsoft.NET.Sdk.StaticWebAssets.Tests/​StaticWebAssetsBaselines/​BuildProjectWithReferences_CorrectlyBundlesScopedCssFiles.Build.files.json Updates scoped CSS baseline.
test/​Microsoft.NET.Sdk.StaticWebAssets.Tests/​StaticWebAssetsBaselines/​Build_WithExternalProjectReference_UpdatesAssets.Build.files.json Updates external-reference baseline.
test/​Microsoft.NET.Sdk.StaticWebAssets.Tests/​StaticWebAssetsBaselines/​Build_UpdatesManifest_WhenFilesChange.Build.files.json Updates manifest-change baseline.
test/​Microsoft.NET.Sdk.StaticWebAssets.Tests/​StaticWebAssetsBaselines/​Build_UpdatesManifest_WhenFilesChange_Updated.Build.files.json Updates changed-file baseline.
test/​Microsoft.NET.Sdk.StaticWebAssets.Tests/​StaticWebAssetsBaselines/​Build_GeneratesJsonManifestAndCopiesItToOutputFolder.Build.files.json Updates manifest-generation baseline.
test/​Microsoft.NET.Sdk.StaticWebAssets.Tests/​StaticWebAssetsBaselines/​Build_FingerprintsContent_WhenEnabled.Build.files.json Updates fingerprinting baseline.
test/​Microsoft.NET.Sdk.StaticWebAssets.Tests/​StaticWebAssetsBaselines/​Build_DoesNotFailToCompress_TwoAssetsWith_TheSameContent.Build.files.json Updates duplicate-compression baseline.
test/​Microsoft.NET.Sdk.StaticWebAssets.Tests/​StaticWebAssetsBaselines/​Build_Detects_PrecompressedAssets.Build.files.json Updates precompression baseline.
test/​Microsoft.NET.Sdk.StaticWebAssets.Tests/​StaticWebAssetsBaselines/​Build_CrosstargetingTests_CanIncludeBrowserAssets.Build.files.json Updates cross-targeting baseline.
test/​Microsoft.NET.Sdk.StaticWebAssets.Tests/​StaticWebAssetsBaselines/​Build_Can_DisableAssetCaching.Build.files.json Updates asset-caching baseline.
test/​Microsoft.NET.Sdk.StaticWebAssets.Tests/​StaticWebAssetsBaselineFactory.cs Normalizes baseline fingerprints and runtime identifiers.
test/​Microsoft.NET.Sdk.StaticWebAssets.Tests/​StaticWebAssetEndpointsIntegrationTest.cs Updates endpoint expectations.
test/​Microsoft.NET.Sdk.StaticWebAssets.Tests/​JsModulesIntegrationTest.cs Tests build-only browser assets.
test/​Microsoft.NET.Sdk.BlazorWebAssembly.Tests/​WasmJsModulesIntegrationTests.cs Tests WebAssembly activation.
test/​Microsoft.NET.Sdk.BlazorWebAssembly.Tests/​StaticWebAssetsBaselines/​StaticWebAssets_HostedApp_ReferencingNetStandardLibrary_Works.Build.files.json Updates hosted-app baseline.
test/​Microsoft.NET.Sdk.BlazorWebAssembly.Tests/​StaticWebAssetsBaselines/​StaticWebAssets_BuildMinimal_Works.Build.files.json Updates minimal-build baseline.
test/​Microsoft.NET.Build.Tests/​EvaluatorFastPathTests.cs Accounts for template reads.
test/​Microsoft.Extensions.DotNetDeltaApplier.Tests/​WebAssemblyHotReloadClientTests.cs Tests replay and WebAssembly updates.
test/​Microsoft.Extensions.DotNetDeltaApplier.Tests/​Mocks/​TestBrowserRefreshServer.cs Updates provider test infrastructure.
test/​Microsoft.Extensions.DotNetDeltaApplier.Tests/​BrowserToolsEndpointRouterTests.cs Tests provider routing.
test/​Microsoft.Extensions.DotNetDeltaApplier.Tests/​BrowserRefreshServerReplayTests.cs Tests replay ordering and resets.
test/​Microsoft.DotNet.HotReload.Client.Tests/​SharedSecretProviderTests.cs Updates shared-secret coverage.
test/​Microsoft.AspNetCore.Watch.BrowserRefresh.Tests/​BrowserScriptMiddlewareTest.cs Removes legacy script coverage.
test/​Microsoft.AspNetCore.Watch.BrowserRefresh.Tests/​BrowserRefreshTagHelperComponentTest.cs Tests activation and path bases.
test/​dotnet-watch.Tests/​Watch/​NoRestoreTests.cs Updates command argument coverage.
test/​dotnet-watch.Tests/​Watch/​BuildEvaluatorTests.cs Extends evaluator setup.
test/​dotnet-watch.Tests/​TestUtilities/​TestBrowserRefreshServer.cs Updates browser server infrastructure.
test/​dotnet-watch.Tests/​HotReload/​RazorHotReloadTests.cs Updates Razor Hot Reload expectations.
test/​dotnet-watch.Tests/​HotReload/​BuildProjectsTests.cs Updates build-project expectations.
test/​dotnet-watch.Tests/​Build/​EvaluationTests.cs Updates evaluation coverage.
test/​dotnet-watch.Tests/​Build/​EvaluationResultTests.cs Tests preserved build properties.
test/​dotnet-watch.Tests/​Browser/​BrowserToolsEndpointRouterTests.cs Tests authentication and routes.
test/​dotnet-watch.Tests/​Browser/​BrowserToolsBuildOutputsTests.cs Tests key loading and validation.
test/​dotnet-watch.Tests/​Browser/​BrowserTests.cs Updates browser integration coverage.
test/​dotnet-watch.Tests/​Browser/​BrowserRefreshServerTests.cs Tests provider environment and update results.
test/​dotnet-watch-test-browser/​Program.cs Updates the browser test harness.
src/​WebSdk/​Web/​Targets/​Sdk.Server.targets Registers server browser-tools initialization.
src/​WebSdk/​Web/​Targets/​DotNetWatch/​Microsoft.NET.Sdk.BlazorWeb.DotNetWatch.lib.module.js Adds server-side activation.
src/​WasmSdk/​Sdk/​Sdk.targets Registers WebAssembly browser-tools assets.
src/​WasmSdk/​Sdk/​DotNetWatch/​Microsoft.NET.Sdk.WebAssembly.DotNetWatch.lib.module.js.template Adds WebAssembly activation; initialization failures need propagation.
src/​StaticWebAssetsSdk/​Tasks/​EnsureDotNetWatchBrowserToolsKey.cs Generates and validates RSA key pairs; malformed imports need broader validation handling.
src/​StaticWebAssetsSdk/​Targets/​Microsoft.NET.Sdk.StaticWebAssets.targets Imports browser-tools asset generation.
src/​StaticWebAssetsSdk/​Targets/​DotNetWatch/​dotnet-watch-browser-tools.config.js.template Defines generated client configuration.
src/​StaticWebAssetsSdk/​AGENTS.md Documents the browser-tools architecture.
src/​Dotnet.Watch/​Web.Middleware/​StartupHook.cs Removes legacy startup behavior.
src/​Dotnet.Watch/​Web.Middleware/​ResponseStreamWrapper.cs Removes response rewriting.
src/​Dotnet.Watch/​Web.Middleware/​HostingStartup.cs Adds forwarding; mounted path bases require handling.
src/​Dotnet.Watch/​Web.Middleware/​BrowserToolsEnvironment.cs Validates provider configuration.
src/​Dotnet.Watch/​Web.Middleware/​BrowserScriptMiddleware.cs Removes provider-served scripts.
src/​Dotnet.Watch/​Web.Middleware/​BrowserRefreshTagHelperComponent.cs Injects application-hosted configuration.
src/​Dotnet.Watch/​Web.Middleware/​BrowserRefreshMiddleware.cs Removes legacy response middleware.
src/​Dotnet.Watch/​Web.Middleware/​BlazorWasmHotReloadMiddleware.cs Removes legacy replay middleware.
src/​Dotnet.Watch/​Web.Middleware/​BlazorHotReload.js Removes the legacy browser script.
src/​Dotnet.Watch/​Web.Middleware/​ApplicationPaths.cs Defines browser-tools routes.
src/​Dotnet.Watch/​Watch/​UI/​IReporter.cs Adds browser-tools diagnostics.
src/​Dotnet.Watch/​Watch/​Process/​RunningProject.cs Propagates apply failures.
src/​Dotnet.Watch/​Watch/​Process/​ProjectLauncher.cs Updates launcher setup.
src/​Dotnet.Watch/​Watch/​HotReload/​RunningProjectsManager.cs Updates apply-result reporting.
src/​Dotnet.Watch/​Watch/​HotReload/​HotReloadDotNetWatcher.cs Updates build-property handling.
src/​Dotnet.Watch/​Watch/​Build/​EvaluationResult.cs Preserves build properties.
src/​Dotnet.Watch/​Watch/​Build/​BuildUtilities.cs Parses build properties.
src/​Dotnet.Watch/​Watch/​Build/​BuildNames.cs Adds browser-tools property names.
src/​Dotnet.Watch/​Watch/​Browser/​BrowserRefreshServerFactory.cs Loads build-generated keys.
src/​Dotnet.Watch/​Watch/​AppModels/​WebApplicationAppModel.cs Configures provider-backed applications.
src/​Dotnet.Watch/​Watch/​AppModels/​BlazorWebAssemblyHostedAppModel.cs Assigns browser-tools ownership.
src/​Dotnet.Watch/​Watch/​AppModels/​BlazorWebAssemblyAppModel.cs Configures Gateway forwarding.
src/​Dotnet.Watch/​HotReloadClient/​Web/​WebSocketConfig.cs Supports provider host configuration.
src/​Dotnet.Watch/​HotReloadClient/​Web/​WebServerHost.cs Exposes provider endpoints.
src/​Dotnet.Watch/​HotReloadClient/​Web/​WebAssemblyHotReloadClient.cs Sends WebAssembly updates.
src/​Dotnet.Watch/​HotReloadClient/​Web/​StaticWebAssetsManifest.cs Filters generated assets.
src/​Dotnet.Watch/​HotReloadClient/​Web/​StaticWebAsset.cs Identifies generated assets.
src/​Dotnet.Watch/​HotReloadClient/​Web/​SharedSecretProvider.cs Imports generated keys.
src/​Dotnet.Watch/​HotReloadClient/​Web/​MiddlewareEnvironmentVariables.cs Updates provider environment variables.
src/​Dotnet.Watch/​HotReloadClient/​Web/​KestrelWebSocketServer.cs Exposes provider URLs.
src/​Dotnet.Watch/​HotReloadClient/​Web/​BrowserToolsProtocol.cs Defines the provider protocol.
src/​Dotnet.Watch/​HotReloadClient/​Web/​BrowserToolsEndpointRouter.cs Implements provider routing; unknown non-GET routes need contract-correct status handling.
src/​Dotnet.Watch/​HotReloadClient/​Web/​BrowserRefreshServer.cs Hosts the provider; configured allowed origins must be preserved.
src/​Dotnet.Watch/​HotReloadClient/​Web/​BrowserConnection.cs Tracks initialization and replay state.
src/​Dotnet.Watch/​HotReloadClient/​HotReloadClients.cs Aggregates apply results.
src/​Dotnet.Watch/​HotReloadAgent.WebAssembly.Browser/​wwwroot/​Microsoft.DotNet.HotReload.WebAssembly.Browser.lib.module.js Removes the legacy initializer.
src/​Dotnet.Watch/​HotReloadAgent.WebAssembly.Browser/​WebAssemblyHotReload.cs Reports unavailable Hot Reload agents.
src/​Dotnet.Watch/​HotReloadAgent.WebAssembly.Browser/​Microsoft.DotNet.HotReload.WebAssembly.Browser.csproj Updates WebAssembly packaging.
src/​Dotnet.Watch/​dotnet-watch/​Watch/​MsBuildFileSetFactory.cs Updates build file-set handling.
src/​Dotnet.Watch/​dotnet-watch/​Watch/​DotNetWatcher.cs Configures browser tooling per run.
src/​Dotnet.Watch/​AGENTS.md Documents provider behavior; the settings route should be included.
eng/​Signing.props Updates JavaScript signing inputs.

Comment thread src/Dotnet.Watch/AGENTS.md Resolved
@javiercn
javiercn enabled auto-merge (squash) September 21, 2026 15:02
@akoeplinger

Copy link
Copy Markdown
Member

@javiercn the test failures look related

Regenerate the release-named baseline so it includes both build and publish compressed assets produced by the release branch test shape.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@javiercn
javiercn disabled auto-merge September 21, 2026 17:41
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@javiercn
javiercn merged commit f905845 into release/11.0.1xx Sep 21, 2026
27 checks passed
@javiercn
javiercn deleted the javiercn-browser-tools-backport-11-0 branch September 21, 2026 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants