Skip to content

Add Local static web asset mode for server browser tools - #57196

Open
javiercn wants to merge 2 commits into
mainfrom
javiercn-local-static-web-assets
Open

javiercn wants to merge 2 commits into
mainfrom
javiercn-local-static-web-assets

Conversation

@javiercn

Copy link
Copy Markdown
Member

Summary

Introduce AssetMode=Local: assets remain available to their own project but are never exported through project references, regardless of StaticWebAssetProjectMode. Preserve existing All, CurrentProject, and Reference behavior.

Use Local for server Web SDK Hot Reload browser-tools assets to fix #56656. Keep WebAssembly browser-tools assets propagating to their hosting server. Reuse the shared reference-export predicate and existing endpoint projection rather than adding browser-tools-specific filtering or target hooks.

Add focused lifecycle and integration coverage for validation, serialization, compression, local build/publish availability, reference exclusion, ordinary initializer propagation, and hosted WebAssembly. Update related documentation and manifest baselines.

Validation

  • Full isolated Debug redist SDK build succeeded with zero warnings or errors.
  • 132 focused tests passed, followed by 5 strengthened assertion reruns.
  • 35 affected baseline checks passed after regeneration and rebuilding embedded resources.
  • Plain API-to-API Debug build and publish succeeded with ReferenceOutputAssembly=true and false; each project retained its own three browser-tools primaries, gzip alternatives, and serving endpoints, with no browser tools in publish output.
  • All three browser-tools modules returned HTTP 200 from the running application.
  • Restoring All mode reproduced the original missing-initializer-endpoints failure.

The 37 regenerated manifest snapshots contain only 222 All-to-Local metadata changes; unrelated ordering churn was removed.

Keep Local assets available to their own project while excluding them from build and publish project-reference exports regardless of project mode. Preserve WebAssembly browser-tools propagation and existing asset modes, and cover lifecycle, endpoint, compression and plain Web SDK references.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@javiercn
javiercn requested review from a team, lbussell and mthalman as code owners November 18, 2026 12:22
Copilot AI balanced review requested due to automatic review settings November 18, 2026 12:22
@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.

🟡 Changes recommended

Local assets remain reachable through exported discovery patterns, while compressed variants can be exported without their primary assets and cause consumers’ compression negotiation to throw.

2 open issues
What changed in this PR

Adds AssetMode=Local to the .NET SDK’s static web assets pipeline so server Hot Reload browser tools remain available to their owning project without propagating through project references. This addresses #56656 while preserving hosted WebAssembly browser-tools propagation.

Changes:

  • Adds Local-mode validation and reference-export filtering, and enables it for server browser tools.
  • Extends lifecycle and integration coverage for compression, manifests, endpoints, and project references.
  • Updates documentation and 37 manifest baselines.

Baseline filenames below are relative to test/Microsoft.NET.Sdk.StaticWebAssets.Tests/StaticWebAssetsBaselines/, unless another path is shown.

File Description
Rebuild_RegeneratesJsonManifestAndCopiesItToOutputFolder.Build.staticwebassets.json Expects Local browser tools before rebuild.
Rebuild_RegeneratesJsonManifestAndCopiesItToOutputFolder_Rebuild.Build.staticwebassets.json Expects Local browser tools after rebuild.
PublishWorks_With_PrecompressedAssets.Build.staticwebassets.json Updates precompressed publish baseline.
PublishProjectWithReferences_WorksWithStaticWebAssetsV1ClassLibraries.Build.staticwebassets.json Updates legacy-library publish baseline.
PublishProjectWithReferences_PublishSingleFile_GeneratesPublishJsonManifestAndCopiesPublishAssets.Build.staticwebassets.json Updates referenced single-file publish baseline.
PublishProjectWithReferences_NoBuild_GeneratesPublishJsonManifestAndCopiesPublishAssets.Build.staticwebassets.json Updates referenced no-build publish baseline.
PublishProjectWithReferences_IncorporatesInitializersFromClassLibrariesAndPublishesAssetsToTheRightLocation.Build.staticwebassets.json Updates initializer publish baseline.
PublishProjectWithReferences_GeneratesPublishJsonManifestAndCopiesPublishAssets.Build.staticwebassets.json Updates referenced publish baseline.
PublishProjectWithReferences_DifferentBuildAndPublish_LibraryInitializers.Build.staticwebassets.json Updates build/publish initializer baseline.
PublishProjectWithReferences_AppendTargetFrameworkToOutputPathFalse_GeneratesPublishJsonManifestAndCopiesPublishAssets.Build.staticwebassets.json Updates alternate-output-path baseline.
Publish_WithExternalProjectReference_UpdatesAssets.Build.staticwebassets.json Updates external-reference publish baseline.
Publish_PublishSingleFile_GeneratesPublishJsonManifestAndCopiesPublishAssets.Build.staticwebassets.json Updates single-file publish baseline.
Publish_NoBuild_GeneratesPublishJsonManifestAndCopiesPublishAssets.Build.staticwebassets.json Updates no-build publish baseline.
Publish_GeneratesPublishJsonManifestAndCopiesPublishAssets.Build.staticwebassets.json Updates standard publish baseline.
DoesNotFailToCompress_TwoAssetsWith_TheSameContent.Build.staticwebassets.json Updates identical-content compression baseline.
Clean_RemovesManifestFrom_BuildAndIntermediateOutput.Build.staticwebassets.json Updates clean scenario baseline.
CanEnable_CompressionOnAllAssets.Build.staticwebassets.json Updates compress-all baseline.
BuildProjectWithReferences_WorksWithStaticWebAssetsV1ClassLibraries.Build.staticwebassets.json Updates legacy-library build baseline.
BuildProjectWithReferences_NoDependencies_GeneratesJsonManifestAndCopiesItToOutputFolder.Build.staticwebassets.json Updates initial dependency-build baseline.
BuildProjectWithReferences_NoDependencies_GeneratesJsonManifestAndCopiesItToOutputFolder_NoDependencies.Build.staticwebassets.json Updates no-dependencies build baseline.
BuildProjectWithReferences_IncorporatesInitializersFromClassLibraries.Build.staticwebassets.json Updates referenced initializer baseline.
BuildProjectWithReferences_GeneratesJsonManifestAndCopiesItToOutputFolder.Build.staticwebassets.json Updates referenced build baseline.
BuildProjectWithReferences_DeployOnBuild_GeneratesPublishJsonManifestAndCopiesPublishAssets.Build.staticwebassets.json Updates referenced deploy-on-build baseline.
BuildProjectWithReferences_CorrectlyBundlesScopedCssFiles.Build.staticwebassets.json Updates scoped CSS scenario baseline.
Build_WithExternalProjectReference_UpdatesAssets.Build.staticwebassets.json Updates external-reference build baseline.
Build_UpdatesManifest_WhenFilesChange.Build.staticwebassets.json Updates initial file-change baseline.
Build_UpdatesManifest_WhenFilesChange_Updated.Build.staticwebassets.json Updates modified-file baseline.
Build_GeneratesJsonManifestAndCopiesItToOutputFolder.Build.staticwebassets.json Updates standard build baseline.
Build_FingerprintsContent_WhenEnabled.Build.staticwebassets.json Updates fingerprinted browser-tools baseline.
Build_DoesNotUpdateManifest_WhenHasNotChanged.Build.staticwebassets.json Updates unchanged-manifest baseline.
Build_Detects_PrecompressedAssets.Build.staticwebassets.json Updates precompressed discovery baseline.
Build_DeployOnBuild_GeneratesPublishJsonManifestAndCopiesPublishAssets.Build.staticwebassets.json Updates deploy-on-build baseline.
Build_DefaultDocumentAndSpaFallback_CreatesAdditionalEndpoints.Build.staticwebassets.json Updates fallback endpoint baseline.
Build_CrosstargetingTests_CanIncludeBrowserAssets.Build.staticwebassets.json Updates cross-targeting baseline.
Build_CreatesEndpointsForAssets.Build.staticwebassets.json Updates endpoint-generation baseline.
Build_Can_DisableAssetCaching.Build.staticwebassets.json Updates disabled-caching baseline.
test/​Microsoft.NET.Sdk.StaticWebAssets.Tests/​StaticWebAssets/​StaticWebAssetTest.cs Tests Local validation and serialization.
test/​Microsoft.NET.Sdk.StaticWebAssets.Tests/​StaticWebAssets/​ResolveCompressedAssetsTest.cs Tests compression preserving asset mode.
test/​Microsoft.NET.Sdk.StaticWebAssets.Tests/​StaticWebAssets/​GenerateStaticWebAssetsDevelopmentManifestTest.cs Tests Local development-manifest inclusion.
test/​Microsoft.NET.Sdk.StaticWebAssets.Tests/​StaticWebAssets/​GenerateStaticWebAssetEndpointsManifestTest.cs Tests Local build and publish endpoints.
test/​Microsoft.NET.Sdk.StaticWebAssets.Tests/​StaticWebAssets/​ComputeStaticWebAssetsForCurrentProjectTest.cs Tests local inclusion across project modes.
test/​Microsoft.NET.Sdk.StaticWebAssets.Tests/​StaticWebAssets/​ComputeReferenceStaticWebAssetItemsTest.cs Tests reference asset and endpoint exclusion.
test/​Microsoft.NET.Sdk.StaticWebAssets.Tests/​LocalStaticWebAssetsIntegrationTest.cs Adds Local build/publish integration coverage.
test/​Microsoft.NET.Sdk.StaticWebAssets.Tests/​HotReloadBrowserToolsIntegrationTest.cs Covers server references and hosted WebAssembly.
test/​Microsoft.NET.Sdk.BlazorWebAssembly.Tests/​StaticWebAssetsBaselines/​StaticWebAssets_HostedApp_ReferencingNetStandardLibrary_Works.Build.staticwebassets.json Updates hosted-app server asset metadata.
src/​WebSdk/​Web/​Targets/​Sdk.Server.targets Selects Local mode for server browser tools.
src/​StaticWebAssetsSdk/​Tasks/​Data/​StaticWebAsset.cs Defines and validates Local mode.
src/​StaticWebAssetsSdk/​Tasks/​Data/​StaticAssetsManifest.cs Excludes Local assets from reference exports.
src/​StaticWebAssetsSdk/​Targets/​Microsoft.NET.Sdk.StaticWebAssets.targets Documents Local asset metadata.
src/​StaticWebAssetsSdk/​Targets/​Microsoft.NET.Sdk.StaticWebAssets.HotReload.targets Applies configurable browser-tools asset mode.
src/​StaticWebAssetsSdk/​Architecture.md Documents visibility and export semantics.
src/​StaticWebAssetsSdk/​AGENTS.md Updates browser-tools contributor guidance.
.github/​memory/​ARCHITECTURE.md Records server versus WebAssembly ownership.

Review effort: Balanced

Preserve Local visibility for checked-in compressed alternatives and retain their original Content identity for publish cleanup. Omit exported runtime discovery roots containing Local files while retaining explicit shared asset entries and unrelated roots. Cover both paths with build/publish and real ASP.NET Core file-provider regressions.

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

This branch has not been deployed

No deployments
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.

.NET 11 RC2 regression: Web SDK app referencing a Web SDK library fails in Debug: "scoped css bundles do not have matching endpoints"

2 participants