Skip to content

Conversation

@lewing
Copy link
Member

@lewing lewing commented Feb 7, 2026

Summary

Fix a .NET 11 regression causing SRI integrity failures during incremental Blazor WASM builds. Three changes in Microsoft.NET.Sdk.WebAssembly.Browser.targets:

  1. Boot config ContentRoot: Change the boot config's DefineStaticWebAssets ContentRoot from $(OutDir)wwwroot to $(IntermediateOutputPath)
  2. Preload matching: Replace fragile %(FileName)%(Extension)-based scanning with direct references to the boot config output items
  3. WebCil ContentRoot: Change the WebCil DefineStaticWebAssets ContentRoot from $(_WasmBuildOuputPath) ($(OutputPath)wwwroot) to $(IntermediateOutputPath)

Regression

This is a regression in .NET 11 (works in 10.0). It was introduced by dotnet/sdk#52283, which fixed an esproj compression bug by flipping the order in AssetToCompress.TryFindInputFilePath to prefer RelatedAsset (Identity) over RelatedAssetOriginalItemSpec. That fix was correct for esproj, but exposed a latent issue in the WASM SDK targets: the boot config and webcil assets' Identity pointed to a wwwroot copy rather than the actual source files.

Before sdk#52283, OriginalItemSpec happened to point to the real file and was checked first, masking the wrong ContentRoot. After the flip, RelatedAsset (Identity) is checked first, and its stale wwwroot path is used — producing incorrect SRI hashes on incremental builds.

Reported in aspnetcore#65271.

Problem

The WASM boot config file (e.g. dotnet.boot.js) is generated at $(IntermediateOutputPath) (the obj/ folder), but its static web asset was defined with ContentRoot="$(OutDir)wwwroot". This caused DefineStaticWebAssets to compute an Identity pointing to the wwwroot copy rather than the actual file in obj/.

The same issue applied to WebCil asset candidates — files from obj/webcil/, the runtime pack, and other directories were all defined with ContentRoot="$(OutputPath)wwwroot", producing synthetic Identities under wwwroot/ that could become stale during incremental builds.

Fix

1. Boot config ContentRoot

Change ContentRoot to $(IntermediateOutputPath) so the asset Identity matches the real file location on disk. The CopyToOutputDirectory="PreserveNewest" attribute still ensures the file is copied to wwwroot for serving.

This follows Javier's suggestion in dotnet/sdk#52847 to "stop defining these assets with an item spec in the wwwroot folder and just define them in their original location on disk".

2. Preload matching simplification

The _AddWasmPreloadBuildProperties and _AddWasmPreloadPublishProperties targets previously scanned all @(StaticWebAsset) items by %(FileName)%(Extension) to find the boot config asset. This relied on the Identity path containing the fingerprint in the filename, which is an implementation detail of how DefineStaticWebAssets computes Identity based on ContentRoot.

The fix replaces the scanning with direct references to @(_WasmBuildBootConfigStaticWebAsset) and @(_WasmPublishBootConfigStaticWebAsset) — the output items already produced by DefineStaticWebAssets. This is both correct and simpler.

3. WebCil ContentRoot

Change the WebCil DefineStaticWebAssets ContentRoot from $(_WasmBuildOuputPath) to $(IntermediateOutputPath). This means:

  • WebCil-converted files in obj/webcil/ are under $(IntermediateOutputPath), so Identity = physical path (no synthesis needed)
  • Runtime pack files (e.g. dotnet.native.js, ICU .dat files) are outside $(IntermediateOutputPath), so ComputeCandidateIdentity synthesizes Identity under obj/ and creates CopyCandidate entries to materialize the fingerprinted copies

This avoids the stale wwwroot Identity problem while maintaining correct publish behavior through CopyCandidate materialization.

What's not changed

  • Publish boot config ContentRoot (ContentRoot="$(PublishDir)wwwroot"): Publish builds are clean and don't have the incremental staleness problem.

Fixes dotnet/aspnetcore#65271

Copilot AI review requested due to automatic review settings February 7, 2026 03:23
@github-actions github-actions bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Feb 7, 2026
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

Updates the Blazor WASM SDK targets to define the build boot config static web asset from its actual on-disk generation location (obj/) to prevent stale-asset Identity selection during incremental builds (which can lead to incorrect SRI integrity values at runtime).

Changes:

  • Change DefineStaticWebAssets ContentRoot for the build boot config asset from $(OutDir)wwwroot to $(IntermediateOutputPath).

@lewing lewing requested a review from javiercn February 7, 2026 03:33
@lewing lewing marked this pull request as ready for review February 7, 2026 03:33
@lewing lewing requested a review from akoeplinger as a code owner February 7, 2026 03:33
@lewing lewing requested a review from maraf February 7, 2026 03:49
@lewing lewing assigned javiercn and unassigned javiercn and lewing Feb 7, 2026
@lewing lewing added arch-wasm WebAssembly architecture area-Meta os-browser Browser variant of arch-wasm and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Feb 7, 2026
Copilot AI review requested due to automatic review settings February 7, 2026 16:43
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

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

lewing added a commit that referenced this pull request Feb 8, 2026
Canceled AzDO jobs (typically from timeouts) still have pipeline
artifacts containing binlogs. The SendToHelix.binlog contains Helix
job IDs that can be queried directly to recover actual test results.

Discovered while investigating PR #124125 where a 3-hour timeout
caused a WasmBuildTests job to be canceled, but all 226 Helix work
items had actually passed.
lewing added a commit that referenced this pull request Feb 8, 2026
Canceled AzDO jobs (typically from timeouts) still have pipeline
artifacts containing binlogs. The SendToHelix.binlog contains Helix
job IDs that can be queried directly to recover actual test results.

Discovered while investigating PR #124125 where a 3-hour timeout
caused a WasmBuildTests job to be canceled, but all 226 Helix work
items had actually passed.
@lewing
Copy link
Member Author

lewing commented Feb 8, 2026

Canceled WasmBuildTests actually passed ✅

The browser-wasm windows Release WasmBuildTests job in build 1284169 was canceled after the 3-hour timeout, but all Helix work items completed successfully.

Recovery steps:

  1. Downloaded the Logs_Build_Attempt1_browser_wasm_windows_Release_WasmBuildTests pipeline artifact
  2. Loaded the truncated \SendToHelix.binlog\ and extracted 12 Helix job IDs
  3. Queried each job via Helix API — all 226 work items passed (0 failures)
Scenario Server2022 Server2025
NoWorkload-ST ✅ 2/2 ✅ 2/2
NoWebcil-ST ✅ 53/53 + 2/2 ✅ 53/53 + 2/2
Workloads-ST ✅ 53/53 ✅ 53/53
NoFingerprint-ST ✅ 2/2 + 2/2 ✅ 2/2 + 2/2

The failure was purely the AzDO job wrapper timing out while waiting to collect results, not an actual test failure.

lewing added a commit that referenced this pull request Feb 8, 2026
Canceled AzDO jobs (typically from timeouts) still have pipeline
artifacts containing binlogs. The \SendToHelix.binlog\ contains Helix
job IDs that can be queried directly to recover actual test results.

## What changed
- Added **Recovering Results from Canceled Jobs** section to helix skill
SKILL.md
- Documents the workflow: download artifacts → load binlog → extract
Helix job IDs → query Helix API
- Includes concrete example from PR #124125 (226 work items all passed
despite 3h timeout cancellation)
- Added tip about binlog MCP server for structured binlog analysis

## Context
Discovered while investigating #124125 where \�rowser-wasm windows
Release WasmBuildTests\ was canceled after 3 hours. The script reported
no failures (correct — no *failed* jobs) but also couldn't surface that
the tests actually passed. With the documented recovery workflow, the
Helix results were fully recoverable.
CopyToOutputDirectory="PreserveNewest"
CopyToPublishDirectory="Never"
ContentRoot="$(OutDir)wwwroot"
ContentRoot="$(IntermediateOutputPath)"
Copy link
Member

Choose a reason for hiding this comment

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

I believe this needs to happen in other places like the definition of the .wasm files as assets (after webcil conversion).

I believe the important bit here is that ContentRoot + RelativePath must exist for all assets

Copy link
Member Author

Choose a reason for hiding this comment

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

Done. Added a commit that sets per-item ContentRoot metadata on each _WebCilAssetsCandidates item to %(RootDir)%(Directory) (its own directory). This ensures candidateFullPath.StartsWith(normalizedContentRoot) is always true in DefineStaticWebAssets.ComputeCandidateIdentity, so Identity equals the physical file path for all candidates — webcil-converted files in obj/webcil/, runtime pack files in packs/, PDBs from obj/, etc.

The task-level ContentRoot parameter is kept as a fallback but the per-item metadata takes precedence via ComputePropertyValue.

Copilot AI review requested due to automatic review settings February 9, 2026 15:10
@dotnet-policy-service dotnet-policy-service bot added the linkable-framework Issues associated with delivering a linker friendly framework label Feb 9, 2026
@kg
Copy link
Member

kg commented Feb 9, 2026

Bad base commit?

@lewing lewing force-pushed the fix/wasm-compression-stale-files branch from b649bd9 to dc5c351 Compare February 9, 2026 18:46
Copilot AI review requested due to automatic review settings February 9, 2026 18:46
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

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

@lewing
Copy link
Member Author

lewing commented Feb 9, 2026

Bad base commit?

yup, and then github stopped responding

@lewing lewing removed the linkable-framework Issues associated with delivering a linker friendly framework label Feb 9, 2026
@lewing lewing requested a review from javiercn February 9, 2026 20:41
@lewing lewing added this to the 11.0.0 milestone Feb 9, 2026
lewing added a commit that referenced this pull request Feb 9, 2026
## Summary

Work around
[dotnet/dnceng#6072](dotnet/dnceng#6072) in
the CI analysis skill by using the Helix \ListFiles\ endpoint instead of
file URIs from the \Details\ endpoint.

## Problem

The Helix work item Details API (\GET .../workitems/{id}\) has two bugs
in its \Files[].Uri\ values:

1. **Subdirectory flattening**: Files uploaded from subdirectories (e.g.
\xharness-output/logs/test/build.binlog\) get URIs with only the base
filename (\.../files/build.binlog\), so multiple distinct files with the
same base name collide
2. **Unicode rejection**: The \/files/{name}\ endpoint validates against
an ASCII-only regex, rejecting filenames containing unicode characters
(e.g. CJK test directory names like \鿀蜒枛遫䡫煉\)

The previous workaround reconstructed permalink URIs from the \FileName\
field, but this still routed through the broken \/files/\ endpoint which
rejects unicode.

## Fix

Use the separate \ListFiles\ endpoint (\GET .../workitems/{id}/files\)
which returns direct blob storage URIs. These URIs:
- Preserve full subdirectory paths
- Have properly percent-encoded unicode
- Don't route through the permalink/regex validation layer

Verified against PR #124125 CI artifacts: 53 files with unicode paths
all return HTTP 200 via ListFiles blob URIs, vs broken/colliding URIs
from the Details endpoint.
Change the boot config's DefineStaticWebAssets ContentRoot from
wwwroot to  so the asset Identity
points to the actual file location on disk rather than a stale copy
in the output wwwroot folder.

This fixes SRI integrity failures during incremental Blazor WASM builds
where the compressed boot config used a stale fingerprint from the
wwwroot copy instead of the fresh file in obj/.

Fixes aspnetcore#65271
Replace the fragile FileName-based scanning of all StaticWebAsset items
with direct references to _WasmBuildBootConfigStaticWebAsset and
_WasmPublishBootConfigStaticWebAsset. These items are already produced
by the DefineStaticWebAssets task in _GenerateBuildWasmBootJson and
_AddPublishWasmBootJsonToStaticWebAssets respectively.

The previous approach relied on FileName containing the fingerprint
(e.g. dotnet.FINGERPRINT.js), which is an implementation detail of
how DefineStaticWebAssets computes Identity. Using the pipeline's
own output items is correct regardless of ContentRoot or Identity
format.
WebCil candidates come from multiple source directories (obj/webcil/
for converted DLLs, runtime pack for native files, etc.) but were
all defined with ContentRoot pointing to OutputPath/wwwroot.

Use IntermediateOutputPath as ContentRoot instead. Files outside obj/
(e.g., runtime pack native files) get synthesized Identities with
CopyCandidates to materialize the fingerprinted copies. Files already
under obj/ (webcil-converted DLLs) use their physical path directly.

This avoids the stale wwwroot Identity problem that caused SRI
integrity failures during incremental builds, while maintaining
correct publish behavior through CopyCandidate materialization.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch-wasm WebAssembly architecture area-Meta os-browser Browser variant of arch-wasm

Projects

None yet

3 participants