Repository navigation
Conversation
|
Azure Pipelines: Successfully started running 1 pipeline(s). 2 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Move net11 server-hosted browser tooling onto the watch-owned protocol through a fixed loopback HTTP/WebSocket forwarder, including hosted WASM when both sides target net11. Behavior: changed: modern server-hosted applications share provider-owned scripts, state, replay, and connection protocol State: builds; regression coverage follows in the next commit Review hint: verify the fixed destination/route, WebSocket subprotocol forwarding, and explicit TFM selection; legacy hosting startup remains isolated Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 49a13c60-1d66-4321-bfdb-01275ead89d6
Cover HTTP and WebSocket forwarding, provider-hosted resources, reconnect behavior, and explicit net8/net9/net10/net11 and mixed hosted-WASM launch strategies. Behavior: preserved State: complete for modern forwarding and compatibility selection Review hint: the net8-net10 and mixed hosted-WASM rows prove that only all-net11 hosted applications select the provider path Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 49a13c60-1d66-4321-bfdb-01275ead89d6
Stop publishing the provider-hosted client as an application static asset, remove the obsolete legacy-injection switch and test-only launch facade, and reduce launch features to the managed-hot-reload decision. Behavior: preserved: required pre-net11 and mixed hosted-WASM legacy paths remain selected and functional State: complete Review hint: the large baseline deletions are the removed static client asset; the client source remains embedded in and served by dotnet watch Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 49a13c60-1d66-4321-bfdb-01275ead89d6
31a1b74 to
b132702
Compare
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 49a13c60-1d66-4321-bfdb-01275ead89d6
There was a problem hiding this comment.
🟡 Changes recommended
The review found concrete correctness/reliability issues (notably MSBuild FileWrites tracking in WASM targets and unbounded waiting in the test browser) that should be addressed before approval.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR moves the modern “browser tools” (HTTP/WebSocket endpoints, protocol state, and JS client delivery) into dotnet watch for .NET 11+, adds a shared-framework forwarder for server-hosted apps, and wires watch-only activation via reserved MSBuild properties.
Changes:
- Add a loopback-only HTTP/WebSocket forwarding path (
BrowserToolsForwarder) and model-specific activation for modern browser tools underdotnet watch. - Flow reserved
DotNetWatchBuild/DotNetWatchBrowserToolsproperties through watch evaluation and “real” build/restart command invocations. - Update WASM/Web static web assets + baselines/tests to reflect watch-only initializer identity and provider-hosted client modules.
File summaries
| File | Description |
|---|---|
| test/Microsoft.NET.Sdk.StaticWebAssets.Tests/JsModulesIntegrationTest.cs | Adds regression test ensuring the Web initializer is watch/build-only and excluded from publish output. |
| test/Microsoft.NET.Sdk.BlazorWebAssembly.Tests/WasmJsModulesIntegrationTests.cs | Adds matrix test for net8–net11 ensuring only net11 watch builds use the watch-only initializer identity. |
| test/Microsoft.NET.Sdk.BlazorWebAssembly.Tests/StaticWebAssetsBaselines/StaticWebAssets_BuildMinimal_Works.Build.staticwebassets.json | Updates baseline to remove the BrowserTools JS module from the app asset graph. |
| test/Microsoft.NET.Sdk.BlazorWebAssembly.Tests/StaticWebAssetsBaselines/StaticWebAssets_BuildMinimal_Works.Build.files.json | Updates baseline file list to match new WASM asset outputs. |
| test/Microsoft.NET.Sdk.BlazorWebAssembly.Tests/StaticWebAssetsBaselines/StaticWebAssets_Build_Hosted_Works.Build.staticwebassets.json | Updates hosted baseline to remove BrowserTools module assets/endpoints. |
| test/Microsoft.NET.Sdk.BlazorWebAssembly.Tests/StaticWebAssetsBaselines/JSModules_ManifestIncludesModuleTargetPaths.Build.staticwebassets.json | Updates baseline to remove BrowserTools module entries/endpoints. |
| test/Microsoft.NET.Sdk.BlazorWebAssembly.Tests/StaticWebAssetsBaselines/Build_DoesNotGenerateManifestJson_IncludesJSModulesOnBlazorBootJsonManifest.Build.staticwebassets.json | Updates baseline to remove BrowserTools module entries/endpoints. |
| test/Microsoft.Extensions.DotNetDeltaApplier.Tests/BrowserToolsEndpointRouterTests.cs | Adds coverage for provider-served JS module endpoints. |
| test/Microsoft.AspNetCore.Watch.BrowserRefresh.Tests/HostingStartupTest.cs | Updates assertions for “modern provider configured” vs legacy-only wiring. |
| test/Microsoft.AspNetCore.Watch.BrowserRefresh.Tests/BrowserToolsForwarderTest.cs | New forwarder tests validating HTTP and WebSocket forwarding semantics. |
| test/Microsoft.AspNetCore.Watch.BrowserRefresh.Tests/BrowserRefreshTagHelperComponentTest.cs | Updates TagHelper activation to load the modern bootstrap module. |
| test/Microsoft.AspNetCore.Watch.BrowserRefresh.Tests/BrowserRefreshMiddlewareTest.cs | Removes legacy “disable injection” parameterization and updates middleware construction. |
| test/dotnet-watch.Tests/Watch/NoRestoreTests.cs | Updates process-argument assertions to account for reserved watch properties being inserted. |
| test/dotnet-watch.Tests/HotReload/BuildProjectsTests.cs | Updates expected build/restore invocations to include reserved watch properties. |
| test/dotnet-watch.Tests/CommandLine/SubcommandTests.cs | Verifies watch’s MSBuild evaluation command line includes reserved properties. |
| test/dotnet-watch.Tests/Build/EvaluationResultTests.cs | Adds test verifying reserved property override behavior (case-insensitive). |
| test/dotnet-watch.Tests/Browser/BrowserRefreshServerTests.cs | Updates environment configurator expectations and adds forwarding configurator coverage. |
| test/dotnet-watch.Tests/Browser/BlazorWebAssemblyAppModelTests.cs | Updates app-model selection tests for modern vs legacy launch strategies (including mixed TFMs). |
| test/dotnet-watch-test-browser/Program.cs | Updates test browser to prefer modern session.json/connect and optionally reconnect via application forwarding. |
| src/WebSdk/Web/Targets/Sdk.Server.targets | Adds net11+ build-only Web initializer when DotNetWatchBrowserTools=true. |
| src/WebSdk/Web/Targets/DotNetWatch/Microsoft.NET.Sdk.Web.DotNetWatch.lib.module.js | New afterWebStarted module importing the provider bootstrap when needed. |
| src/WasmSdk/Sdk/Sdk.targets | Switches WASM initializer identity to watch-only for net11 watch builds and removes BrowserTools module from the app asset graph. |
| src/Dotnet.Watch/Web.Middleware/StartupHook.cs | Makes BrowserRefresh startup hook a no-op when modern provider forwarding is active. |
| src/Dotnet.Watch/Web.Middleware/HostingStartup.cs | Registers forwarder + TagHelper activation when provider address is configured; legacy path remains for pre-net11/compat. |
| src/Dotnet.Watch/Web.Middleware/BrowserToolsForwarderOptions.cs | New options record for configuring the forwarder provider address. |
| src/Dotnet.Watch/Web.Middleware/BrowserToolsForwarder.cs | New loopback-only HTTP/WebSocket forwarder implementation. |
| src/Dotnet.Watch/Web.Middleware/BrowserToolsEnvironment.cs | Adds provider address parsing/validation for modern forwarding activation. |
| src/Dotnet.Watch/Web.Middleware/BrowserRefreshTagHelperComponent.cs | Switches injected activation script to the modern bootstrap module. |
| src/Dotnet.Watch/Web.Middleware/BrowserRefreshMiddleware.cs | Removes legacy injection toggle; legacy rewrite path is now always enabled when this middleware runs. |
| src/Dotnet.Watch/Web.Middleware/ApplicationPaths.cs | Adds modern fixed route constants for /_framework/dotnet-browser-tools. |
| src/Dotnet.Watch/Watch/HotReload/HotReloadDotNetWatcher.cs | Ensures reserved watch properties are passed through MSBuild-based restart builds. |
| src/Dotnet.Watch/Watch/Build/EvaluationResult.cs | Ensures reserved watch properties are always set for design-time evaluation properties. |
| src/Dotnet.Watch/Watch/Build/BuildUtilities.cs | Adds case-insensitive build-property parsing into an immutable dictionary. |
| src/Dotnet.Watch/Watch/Build/BuildNames.cs | Introduces reserved property name constants for watch flow. |
| src/Dotnet.Watch/Watch/AppModels/WebApplicationAppModel.cs | Selects forwarding vs legacy launch configurator based on .NET 11+ support and adjusts WebSocket hostname behavior. |
| src/Dotnet.Watch/Watch/AppModels/BlazorWebAssemblyHostedAppModel.cs | Uses modern path only when both client and server TFMs are .NET 11+; otherwise keeps legacy behavior. |
| src/Dotnet.Watch/Watch/AppModels/BlazorWebAssemblyAppModel.cs | Uses Gateway proxy launch configurator for net11+ standalone WASM; otherwise uses legacy hosting-startup path. |
| src/Dotnet.Watch/HotReloadClient/Web/WebSocketConfig.cs | Adds WithHostName helper used to force loopback hostname for modern provider mode. |
| src/Dotnet.Watch/HotReloadClient/Web/MiddlewareEnvironmentVariables.cs | Replaces legacy HTML injection env var with provider-address env var constant. |
| src/Dotnet.Watch/HotReloadClient/Web/IBrowserToolsLaunchConfigurator.cs | Removes BrowserToolsLaunchFeatures flags enum in favor of explicit configurator selection. |
| src/Dotnet.Watch/HotReloadClient/Web/HostingStartupBrowserToolsLaunchConfigurator.cs | Switches to explicit enableManagedHotReload boolean and removes legacy HTML injection env-var emission. |
| src/Dotnet.Watch/HotReloadClient/Web/ForwardingBrowserToolsLaunchConfigurator.cs | New configurator emitting provider-address + activation via hosting-startup assembly resolution. |
| src/Dotnet.Watch/HotReloadClient/Web/BrowserToolsProtocol.cs | Adds new paths for provider-served client + bootstrap modules. |
| src/Dotnet.Watch/HotReloadClient/Web/BrowserToolsEndpointRouter.cs | Adds endpoints serving the provider-hosted browser client and bootstrap modules from embedded resources. |
| src/Dotnet.Watch/HotReloadClient/Web/AbstractBrowserRefreshServer.cs | Removes old “configure env” helper; caller now selects configurator explicitly. |
| src/Dotnet.Watch/HotReloadClient/Microsoft.DotNet.HotReload.Client.projitems | Embeds the browser-tools client JS module as an assembly resource for provider serving. |
| src/Dotnet.Watch/HotReloadAgent.WebAssembly.Browser/wwwroot/Microsoft.DotNet.HotReload.WebAssembly.BrowserTools.lib.module.js | Expands JS module to include provider discovery and reconnect/reload behavior. |
| src/Dotnet.Watch/HotReloadAgent.WebAssembly.Browser/wwwroot/Microsoft.DotNet.HotReload.WebAssembly.Browser.lib.module.js | Adjusts runtime initializer to use provider-hosted client and gate modern probing on watch-only identity. |
| src/Dotnet.Watch/dotnet-watch/Watch/MsBuildFileSetFactory.cs | Ensures evaluation and watch-list generation include reserved properties. |
| src/Dotnet.Watch/dotnet-watch/Watch/DotNetWatcher.cs | Updates environment setup to use the new launch configurator signature. |
| src/Dotnet.Watch/dotnet-watch/Watch/BuildEvaluator.cs | Inserts reserved properties into supported subcommands before application arguments (--). |
| src/Dotnet.Watch/AGENTS.md | Updates contributor guidance for modern provider/forwarder ownership and activation behavior. |
| eng/Signing.props | Removes signing entry for BrowserTools JS module now served from embedded resource/provider. |
| .github/memory/ARCHITECTURE.md | Documents the reserved-property flow and net11+ watch-only initializer selection at a high level. |
Review details
- Files reviewed: 54/54 changed files
- Comments generated: 3
- Review effort level: Lite
| if (!Uri.TryCreate(value, UriKind.Absolute, out var address) || | ||
| address.Scheme != Uri.UriSchemeHttp || | ||
| !IsLoopbackHost(address)) | ||
| { | ||
| throw new InvalidOperationException($"The configured browser tools provider address '{value}' is not a loopback HTTP address."); | ||
| } |
| <FileWrites Include="$(_WasmHotReloadIntermediatePath)Microsoft.DotNet.HotReload.WebAssembly.Browser.lib.module.js" /> | ||
| <FileWrites Include="$(_WasmHotReloadIntermediatePath)Microsoft.DotNet.HotReload.WebAssembly.BrowserTools.lib.module.js" /> | ||
| <FileWrites Include="$(_WasmHotReloadIntermediatePath)Microsoft.DotNet.HotReload.WebAssembly.Browser.Watch.lib.module.js" /> | ||
| <FileWrites Include="$(_WasmHotReloadIntermediatePath)Microsoft.DotNet.HotReload.WebAssembly.Browser.dll" /> |
| while (true) | ||
| { | ||
| try | ||
| { | ||
| using var response = await httpClient.GetAsync(sessionUrl); | ||
| if (response.IsSuccessStatusCode) | ||
| { | ||
| return; | ||
| } | ||
| } | ||
| catch (HttpRequestException e) | ||
| { | ||
| Console.WriteLine($"Waiting for browser tools route: {e.Message}"); | ||
| } | ||
|
|
||
| await Task.Delay(100); | ||
| } |
|
Due to lack of recent activity, this PR has been labeled as 'Stale'. It will be closed if no further activity occurs within 7 more days. Any new comment will remove the label. |
Dependency
Stacked on and depends on #56072. Review this PR relative to
javiercn-mvc-taghelper-browser-tools; it contains only the unified forwarding, rationalization, and watch-only activation layer.Summary
dotnet watch.ITagHelperComponent, Blazor Web uses a build-onlyafterWebStartedinitializer, and standalone WASM uses its runtime initializer.DotNetWatchBuildandDotNetWatchBrowserToolsproperties through watch graph evaluation, real builds, and MSBuild-based restart commands. Reserved values override user properties case-insensitively; property-incompatible commands such asformatare unchanged.dotnet runstill loads the normal build-only initializer but no longer probessession.json, eliminating the inactive 404.Retained compatibility boundary
The legacy implementation remains only for demonstrated consumers: pre-.NET 11 MVC/Razor Pages and generic browser refresh, older or mixed-TFM hosted WASM, and legacy
blazor-hotreloadclients. Those paths retain response rewriting, legacy scripts/endpoints, boot headers, WebSocket endpoint/key configuration, and virtual-directory behavior. Unsupported custom/static HTML still requires user-provided activation; noindex.htmlrewrite is introduced.The watch-only Web and WASM initializer selection starts at net11. Net8/net9 receive no implicit WASM Hot Reload initializer, net10 retains the normal initializer plus legacy BrowserRefresh activation, and plain/publish outputs do not contain the new Web initializer.
Final manual validation
All scenarios used
artifacts\bin\redist\Debug\dotnet\dotnet.exefrom external real-app directories afterbuild.cmd -noblcompleted with 0 warnings and 0 errors..NET 11 Blazor Web SSR
Command:
The deliberately lower-cased false user properties were overridden by the reserved watch values. The browser loaded exactly one fingerprinted
Microsoft.NET.Sdk.Web.DotNetWatch.*.lib.module.js;session.jsonreturned 200; the provider client connected; and a Razor heading edit renderedSSR reserved properties activeafter the watch log reportedC# and Razor changes applied in 1896mswithout restart.dotnet.exe run --project .\Net11BlazorSsrManual.csproj -- --urls http://127.0.0.1:5317loaded no watch initializer, made no browser-tools request, and did not connect. A watch run withDOTNET_WATCH_SUPPRESS_BROWSER_REFRESH=1likewise loaded no initializer/client..NET 11 standalone Gateway WASM
Command:
The browser loaded exactly one fingerprinted
.Watch.*.lib.module.js;session.jsonreturned 200; the Gateway/YARP log showed provider HTTP forwarding and a 101 WebSocket upgrade; and a Razor edit renderedWatch filename signal validated!afterC# and Razor changes applied in 1663mswithout restart.dotnet.exe run --project .\GatewayHotReloadApp.csproj -- --urls http://127.0.0.1:5318loaded only the normal initializer identity. In a fresh browser tab it made zerodotnet-browser-toolsrequests and remained disconnected, confirming the inactivesession.json404 is gone..NET 10 standalone WASM compatibility
Command:
The browser loaded exactly one
aspnetcore-browser-refresh.jsand the normal WASM initializer, made zero modern provider requests, and stayed off the modern connection sentinel. A Razor edit renderedNET10 LEGACY PATH REVALIDATEDafterC# and Razor changes applied in 1771mswithout restart.Restart-style command compatibility
formatcompleted and entered the normal wait-for-change state; it did not receive unsupported-p:arguments or report an unrecognized option.Earlier manual validation on this PR also covered real net8/net9/net10 Razor Pages, net11 MVC/Razor Pages, net11 hosted WASM managed update/replay/CSS, standalone Gateway WASM HTTP/WebSocket forwarding, legacy hosted WASM, PathBase, HTTPS/WSS, multiple pages, restart recovery, cache clearing, and inactive plain
dotnet run.Manual-environment-only adjustments in those earlier scenarios: unavailable rc.1 WASM pack versions were overridden to locally available preview.7 packs; installed ASP.NET Core 8.0.30, 9.0.19, and 10.0.11 runtime folders were copied into the redist layout for real older-TFM runs. The final validation above required only alternate unused ports. No credential-provider or product workaround was used.
Automated validation
build.cmd -nobl— succeeded with 0 warnings and 0 errors.dotnet-watch.Testsproperty/build/format coverage — 41 passed.JsModulesIntegrationTest.DotNetWatchBrowserToolsInitializer_IsWatchOnlyAndBuildOnly— 1 passed.WasmJsModulesIntegrationTests.Build_UsesWatchInitializerOnlyForNet11BrowserToolsBuilds— 5 passed across net8, net9, net10, net11 plain, and net11 watch rows, asserting exactly one appropriate initializer identity.Design notes
DOTNET_MODIFIABLE_ASSEMBLIES, and__ASPNETCORE_BROWSER_TOOLSremain runtime launch configuration and are not embedded as build-time dynamic values.DOTNET_STARTUP_HOOKSonly so the out-of-app hosting-startup assembly can be resolved. Its startup hook is a no-op in modern mode; the separate DeltaApplier startup hook remains active for managed server updates.