Skip to content

fix(sdk): Move WebGPU usage detection into Uno.Sdk - #25580

Merged
ramezgerges merged 3 commits into
unoplatform:masterfrom
ramezgerges:dev/rara/webgpu-detect-task
Oct 23, 2026
Merged

ramezgerges merged 3 commits into
unoplatform:masterfrom
ramezgerges:dev/rara/webgpu-detect-task

Conversation

@ramezgerges

@ramezgerges ramezgerges commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

GitHub Issue: closes #25336

PR Type:

🐞 Bugfix

What changed? 🚀

Any app that names the webgpu feature against a CI-built Uno.Sdk fails with:

error MSB4062: The "Uno.Sdk.Tasks.DetectWebGpuUsage_v0" task could not be loaded from the assembly ...\Uno.Sdk_<sha>.dll

Packaging (UpdateTasksSHA) rewrites v0 to the commit in every file under src/Uno.Sdk. That renames both the task classes and Uno.Sdk_v0.dll. The WebGpu package registered and called DetectWebGpuUsage_v0 from its own NativeTrim.targets, outside that rewrite. So it pointed at the rewritten assembly by a class name that no longer exists.

This PR moves the UsingTask and the _UnoWebGpuDetectUsage target into a new src/Uno.Sdk/targets/Uno.WebGpu.targets, imported by Sdk.targets. They're now rewritten together with the assembly they name, like every other SDK task.

  • The WebGpu package opts in by setting _UnoWebGpuNativeTrim, which keeps today's behaviour: detection runs whenever the package's targets are imported.
  • The package keeps only the targets that drop the native payload. They run after _UnoWebGpuDetectUsage or ILLink, unchanged.

The SDK registers the task from its own path ($(MSBuildThisFileDirectory)netstandard2.0\Uno.Sdk_v0.dll), like Uno.AppLaunch.targets and Uno.Implicit.Packages.targets. The UnoSdkTasksAssembly property is removed, so no package can point at the SDK's assembly again. A missing assembly is now a build error rather than a silent skip.

Packaging now also fails if a packaged MSBuild file outside _Sha1Replace names a _v0 symbol. That covers build/nuget, and every buildTransitive and package folder under src, which is the class of bug behind #25336.

Mixed versions:

  • New package, older SDK: nothing runs the detection, so _UnoWebGpuNativeUnused is never set and the wgpu payload is kept.
  • Older package, new SDK: the package still defines _UnoWebGpuDetectUsage, and since it's imported later, its definition overrides the SDK's. That target is gated on UnoSdkTasksAssembly, which this SDK no longer sets, so it skips, and the payload is kept with no MSB4062.

Validation

Against a locally packed Uno.Sdk with v0 rewritten by UpdateTasksSHA (a probe net10.0-desktop app with UnoFeatures Skia;WebGpu):

WebGpu package App uses the backend Result
this branch no "Nothing in this app goes near WebGPU… payload is omitted", no webgpu.dll / libwebgpu.* in the output
this branch yes "Keeping the wgpu native payload: TrimProbe.dll references Uno.UI.Composition.WebGpu", payload shipped
published 7.0.0-dev.2420 no builds with no MSB4062, payload kept

The renamed DetectWebGpuUsage_<sha> loaded from Uno.Sdk_<sha>.dll.

Earlier, using Uno Chefs (skia;webgpu) against the published SHA-rewritten Uno.Sdk 7.0.0-dev.81 and Uno.WinUI.Composition.WebGpu 7.0.0-dev.2347:

  • Before: MSB4062 in Uno.WinUI.Composition.WebGpu.NativeTrim.targets(30,3), reproducing the issue.
  • After: with this change applied to the extracted packages, the build passes and keeps the payload, since Chefs references the backend.

The _v0 packaging check fails on a planted _v0 reference and passes on this branch.

The detection logic moved verbatim, apart from the opt-in condition.

Not covered by CI: the Skia;WebGpu cases in run-netcore-mobile-template-tests.ps1 would exercise the packed path, but their job in .azure-devops-tests-templates.yml is condition: false. Re-enabling it is a separate change.

PR Checklist ✅

  • 🧪 Added Runtime tests, UI tests, or a manual test sample (for bug fixes / features, if applicable) (build-infrastructure change, validated against a packed SDK as described above)
  • 📚 Docs have been added/updated following the documentation template (for bug fixes / features) (no docs reference these targets)
  • 🖼️ Validated PR Screenshots Compare Test Run results.
  • ❗ Contains NO breaking changes
  • 👀 Reviewed 2 other open pull requests (optional but appreciated!)

🤖 Generated with Claude Code

Packaging rewrites "v0" to the commit in the files under src/Uno.Sdk,
which renames both the task classes and Uno.Sdk_v0.dll. The WebGpu
package registered and called DetectWebGpuUsage_v0 from its own targets,
outside that rewrite, so a packed SDK no longer had a task by that name
and every app naming the webgpu feature failed with MSB4062.

The registration and the target that runs the task now live in the SDK,
next to the assembly they name, and are rewritten with it. The package
opts in with _UnoWebGpuNativeTrim and keeps only the targets that drop
the native payload. Against an SDK without the detection nothing sets
_UnoWebGpuNativeUnused, so the payload is kept.

Fixes unoplatform#25336

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@unodevops

Copy link
Copy Markdown
Contributor

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

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 240212 has failed on Uno.UI - CI.

@ramezgerges

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@unodevops

Copy link
Copy Markdown
Contributor

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

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 240359 has failed on Uno.UI - CI.

@Xiaoy312 Xiaoy312 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.

Non-blocking notes:

  1. CI doesn't test this fix. run-netcore-mobile-template-tests.ps1 already has the Skia;WebGpu cases that would have caught the bug, but their job in .azure-devops-tests-templates.yml is condition: false. In-repo builds use the un-rewritten _v0 names, so nothing in CI runs the packed path. A small follow-up check would help: flag any _v0 reference in files that _Sha1Replace doesn't cover. That's the same class of bug.

  2. The validation only covered keeping the payload. Chefs references the backend, so the log shows "Keeping the wgpu native payload". Dropping the payload (_UnoWebGpuNativeUnused=true, then the files are removed) wasn't run against a SHA-rewritten SDK. The risk is low since the logic moved verbatim. Still, a skia;webgpu app that never touches the backend should log "…payload is omitted" and ship no webgpu.dll.

  3. The description overstates "older package, new SDK". The old package still defines _UnoWebGpuDetectUsage, and since it's imported later, its definition silently overrides the SDK's. So the override decides the outcome, not the missing opt-in property. That path also still fails with MSB4062 against a rewritten SDK. "Behaves as it does today" is accurate, but "fail safe" isn't.

  4. Nit: UnoSdkTasksAssembly is now only used inside the SDK. It was added so packages could find the SDK DLL, which is the pattern that caused this bug. The other SDK registrations (Uno.AppLaunch.targets, Uno.Implicit.Packages.targets) use $(MSBuildThisFileDirectory)netstandard2.0\Uno.Sdk_v0.dll directly. Switching to the direct path and dropping or underscoring the property would discourage the next package from relying on it. The Exists() checks also turn a missing DLL into a silent skip that keeps the payload, rather than an error that would expose a packing bug.

  5. Nit: the 15-line comment block in Uno.WebGpu.targets is long for repo style. It mostly carries the old rationale over, so it's fine either way.

@ramezgerges
ramezgerges enabled auto-merge October 21, 2026 17:34
@ramezgerges
ramezgerges disabled auto-merge October 21, 2026 17:35
@mergify

mergify Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

The task now loads from the sdk's own assembly path, like the other sdk
task registrations, instead of an UnoSdkTasksAssembly property that
packages could rely on. A missing assembly is now a build error rather
than a silent skip.

Packaging also fails when a packaged MSBuild file outside _Sha1Replace
still names _v0, the class of bug behind unoplatform#25336.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@github-actions github-actions Bot added the area/build Categorizes an issue or PR as relevant to build infrastructure label Oct 21, 2026
@ramezgerges

Copy link
Copy Markdown
Contributor Author

Thanks, addressed in 895f389:

  1. CI coverage: UpdateTasksSHA now fails packaging if a packaged MSBuild file outside _Sha1Replace names a _v0 symbol. It checks build/nuget, and every buildTransitive and package folder under src. It fails on a planted reference and passes on this branch. Re-enabling the template-test job (condition: false) is a separate change, so I left it out of this PR.
  2. Payload drop: validated against a locally packed, SHA-rewritten SDK, with a Skia;WebGpu app that never names the backend. It logs "…payload is omitted" and ships no webgpu.dll / libwebgpu.*. The same app referencing WebGpuBackend keeps the payload. The table is in the description.
  3. Older package, new SDK: you're right that the package's own target overrides the SDK's. That target is gated on UnoSdkTasksAssembly, and with 4 that property is gone, so it now skips cleanly. The published 7.0.0-dev.2420 package against the rewritten SDK builds with no MSB4062 and keeps the payload. I reworded the description.
  4. UnoSdkTasksAssembly: removed. The task registers from $(MSBuildThisFileDirectory)netstandard2.0\Uno.Sdk_v0.dll like the other SDK registrations, with no Exists() gate, so a missing DLL is an error.
  5. Comment: shortened to four lines.

@ramezgerges
ramezgerges enabled auto-merge October 21, 2026 18:02
The repo imports Uno.Sdk from source, where no task assembly sits beside
the targets, so the now-mandatory detection task failed to load (MSB4062)
in the SamplesApp wasm head. A repo head always reaches WebGPU, so there
is nothing to trim there.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@unodevops

Copy link
Copy Markdown
Contributor

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

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 240876 has failed on Uno.UI - CI.

@ramezgerges
ramezgerges merged commit c4c047d into unoplatform:master Oct 23, 2026
51 checks passed
ramezgerges added a commit to unoplatform/uno.chefs that referenced this pull request Oct 26, 2026
dev.89 ships the WebGPU usage detection inside Uno.Sdk (unoplatform/uno#25580),
so builds with the WebGpu feature no longer fail with MSB4062 on
DetectWebGpuUsage_v0, and it pins the Toolkit 11 / Extensions 8 builds that
match Uno 7.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/build Categorizes an issue or PR as relevant to build infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Building with the WebGpu feature fails with MSB4062 for DetectWebGpuUsage_v0 in a CI-built Uno.Sdk

4 participants