Skip to content

fix: Keep .uprimarker from posing as its assembly (net11 WASM startup) - #26292

Merged
MartinZikmund merged 2 commits into
masterfrom
dev/mazi/uprimarker-metadata
Nov 10, 2026
Merged

MartinZikmund merged 2 commits into
masterfrom
dev/mazi/uprimarker-metadata

Conversation

@MartinZikmund

@MartinZikmund MartinZikmund commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

GitHub Issue: closes #26289

PR Type:

🐞 Bugfix

What changed? 🚀

Symptom

A net11.0-browserwasm Uno app never gets past the splash screen:

Could not load file or assembly 'Uno.UI.Runtime.WebAssembly.Browser, Version=255.255.255.255, ...'

Uno.UI.Runtime.WebAssembly.Browser is missing from the boot manifest (_framework/dotnet.js). The file deployed as _framework/Uno.UI.Runtime.WebAssembly.Browser.dll is actually the package's 132-byte .uprimarker text file. The four Uno.Fonts.* assemblies are dropped in the same way: their 0-byte markers replace them. That doesn't block startup, but it's the same bug.

Root cause (Uno side)

_UnoFindPackageAssetMarkers builds marker items with an item transform:

<_UnoPriFiles Include="@(RuntimeCopyLocalItems->'%(RootDir)%(Directory)%(Filename).uprimarker')" ... />
<ReferenceCopyLocalPaths Include="@(_UnoPriFiles)"/>

An item transform copies all metadata from the source item, so each marker reaches ReferenceCopyLocalPaths still carrying its assembly's metadata:

Metadata Value on Foo.uprimarker before this PR
DestinationSubPath Foo.dll
AssetType runtime
PathInPackage lib/<tfm>/Foo.dll

To any downstream consumer, the marker looks like a second copy of Foo.dll.

Why it only breaks on .NET 11 (and why net10 is fine)

The WASM SDK's ComputeWasmBuildAssets task (in Microsoft.NET.Sdk.WebAssembly.Pack) gives each candidate a RelativePath with AssetsComputingHelper.GetCandidateRelativePath. That helper prefers DestinationSubPath when present. It's the same in 10.0.14 and 11.0.0-rc.3 (checked by decompiling both packs). So in both versions, the marker and the real DLL resolve to _framework/Foo.dll.

The difference is what happens next:

  • .NET 10: every candidate goes into the output list with no duplicate check. The real DLL survives, is converted to webcil (Foo.wasm) and is listed in the boot manifest. The marker also ends up under the same path, but nothing loads it, so the problem stays hidden.
  • .NET 11: the task keeps a HashSet<string> of relative paths and drops any later candidate whose path is already taken:
    Skipping duplicate relative path '_framework/Uno.UI.Runtime.WebAssembly.Browser.dll' for candidate '...\Uno.UI.Runtime.WebAssembly.Browser.dll'
    
    The marker comes first in the list, so it takes the slot and the real assembly never reaches the manifest.

The Uno target hasn't changed in years (it's the same in 6.7 and 7.0). It became fatal once the .NET 11 WASM SDK started deduplicating by relative path. That's why every Uno version fails on net11.0-browserwasm and passes on net10.0-browserwasm.

Fix

Markers are now added to ReferenceCopyLocalPaths with their own identity:

<ReferenceCopyLocalPaths Include="@(_UnoPriFiles)"
                         KeepMetadata="NuGetPackageId;NuGetPackageVersion;PublishFolderType">
    <DestinationSubPath>%(Filename)%(Extension)</DestinationSubPath>
</ReferenceCopyLocalPaths>
  • DestinationSubPath becomes Foo.uprimarker, so the marker no longer competes with the DLL for its slot.
  • AssetType and PathInPackage are dropped, so no SDK treats the marker as a runtime assembly.
  • The package identity and PublishFolderType="None" are kept. Markers are still copied next to their assembly in bin/.
  • The only consumer of _UnoPriFiles, ExpandPackageAssets, reads just FullPath, so dropping the other metadata is safe.

The fix is in the shared target, so it covers every head (not only WASM) and the Xamarin-style Reference path as well. On non-WASM heads the only change is that the marker stops claiming its DLL's metadata, which was never correct.

Tests

Given_PackageAssetMarkers (in Uno.UI.Tasks.Tests) imports the real uno.ui.tasks.assets.targets, runs _UnoFindPackageAssetMarkers against a fake package containing Foo.dll and Foo.uprimarker, and reads ReferenceCopyLocalPaths back with dotnet msbuild -getItem. It asserts that the marker has DestinationSubPath=Foo.uprimarker, no AssetType and no PathInPackage, and still has its NuGetPackageId.

  • Without the fix it fails: DestinationSubPath is Foo.dll.
  • With the fix it passes.

Validation

  • Unit test: Given_PackageAssetMarkers fails before the fix and passes after it (run locally on net10.0).
  • SDK analysis: I decompiled ComputeWasmBuildAssets and AssetsComputingHelper from Microsoft.NET.Sdk.WebAssembly.Pack 10.0.14 and 11.0.0-rc.3.26522.148 to confirm the shared DestinationSubPath-based relative path and the .NET 11-only dedup.
  • End-to-end: the fix produces the same marker metadata as the workaround in the issue, which the reporter confirmed restores all five assemblies in the boot manifest (304 vs 299 entries) and starts the app in Firefox 159. I haven't re-run a full net11.0-browserwasm app build locally because the wasm-tools workload for the 11.0 rc SDK isn't installed on this machine.

PR Checklist ✅

🤖 Generated with Claude Code

https://claude.ai/code/session_01TXMNtytE1VJhzMyGQcg5jf

MartinZikmund and others added 2 commits November 10, 2026 16:46
The marker items were built with an item transform from the package's
assembly, so they inherited its DestinationSubPath, AssetType and
PathInPackage. The .NET 11 WASM SDK keeps one asset per relative path,
so the marker won `_framework/<Assembly>.dll` and the real DLL was
dropped from the boot manifest.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TXMNtytE1VJhzMyGQcg5jf
Copilot AI balanced review requested due to automatic review settings November 10, 2026 15:49

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 was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@mergify

mergify Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

This pull request is merged.

@github-actions github-actions Bot added the area/code-generation Categorizes an issue or PR as relevant to code generation label Nov 10, 2026
@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 15s —— View job


Review of #26292

Verdict: ship. No blocking issues, so I posted no inline comments.

Issues by severity: 0 blocking, 0 major, 0 minor.

What I checked (code review by inspection only; I did not build or run anything):

  • Root cause: the fix targets the actual defect. The item transform copies the DLL's metadata onto the marker, so Foo.uprimarker claimed DestinationSubPath=Foo.dll. Overriding DestinationSubPath and restricting metadata with KeepMetadata removes the collision at its source, rather than adding a downstream guard. It is a root-cause fix.
  • Scope: the change is in the shared _UnoFindPackageAssetMarkers target, so both the RuntimeCopyLocalItems path and the Xamarin-style Reference path get it.
  • Metadata kept: NuGetPackageId, NuGetPackageVersion and PublishFolderType are kept, so the markers still copy to bin/ and stay excluded from publish.
  • Test: Given_PackageAssetMarkers follows the existing DotnetMSBuild and -getItem pattern used in Given_UnoSdkRendererFeature. It asserts the fixed metadata and cleans up its temp directory. The PR description says it was red before the fix and green after.
  • Style and conventions: tabs, braces, the Conventional Commit title and the linked issue all conform to AGENTS.md.

Non-blocking observations:

  • The test only covers the RuntimeCopyLocalItems branch. The ProjectTypeGuids (Reference) branch is untested. It uses the same final ItemGroup, so the risk is low.
  • The end-to-end net11.0-browserwasm run was not performed, as the description states. The reporter's confirmation of the equivalent workaround is reasonable evidence. If CI has a net11 WASM lane, it would give a stronger signal.

@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@MartinZikmund
MartinZikmund merged commit 985299d into master Nov 10, 2026
55 checks passed
@MartinZikmund
MartinZikmund deleted the dev/mazi/uprimarker-metadata branch November 10, 2026 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/code-generation Categorizes an issue or PR as relevant to code generation

Projects

None yet

6 participants