Skip to content

Trimmed .NET 10 WinAppSDK app crashes at startup: Uno.WinUI swaps in its net9 Uno.UI.Toolkit.dll, which skips the linker #24577

Closed

Description

@MartinZikmund

Current behavior 🐛

A packaged WinAppSDK head on .NET 10 with trimming on (PublishTrimmed=true, TrimMode full or partial) crashes about 3 seconds after launch. WER reports 0xc000027b in Microsoft.UI.Xaml.dll with 0x802B000A (E_XAMLPARSEFAILED). A first-chance exception log shows why:

System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
   at DailyPlants.DailyPlants_XamlTypeInfo.XamlTypeInfoProvider.InitTypeTables()
   at DailyPlants.DailyPlants_XamlTypeInfo.XamlTypeInfoProvider.LookupTypeIndexByName(String typeName)

The untrimmed package runs fine. The Uno and WinUI publish profiles (Properties/PublishProfiles/win-*.pubxml) turn trimming on for Release, so a Release "package and publish" produces a package that crashes.

Root cause: in Uno.WinUI's buildTransitive/uno.winui.winappsdk.targets, _UnoRemoveReferences removes the NuGet-resolved Uno.WinUI references. It then re-adds $(PkgUno_WinUI)/lib/net9.0-windows10.0.19041.0/*.dll (a hardcoded TFM) to ReferencePath and ReferenceCopyLocalPaths, even when the app is .NET 10 and NuGet resolved lib/net10.0-windows10.0.19041.0/. In publish:

  • RuntimeCopyLocalItems and _ManagedRuntimeAssembly hold the net10 path (the NuGet asset).
  • ResolveOverlappingItemGroupConflicts keeps the net9 path in ResolvedFileToPublish.
  • _ComputeManagedAssemblyToLink joins by path, finds no match, and passes the net9 Uno.UI.Toolkit.dll through untouched. It's never linked or ReadyToRun-compiled; the packaged file is byte-identical to the net9 NuGet file.
  • ILLink removes the facades nothing else references (System.Runtime, System.Runtime.Loader, System.Threading, System.Numerics.Vectors). Uno.UI.Toolkit.dll still references them, so the generated XAML type info fails to load its types.

(Both the net9 and net10 Uno.UI.Toolkit.dll reference System.Runtime 9.0.0.0. That's harmless once the assembly actually goes through the linker.)

The same bypass also means that a blank app which never uses Uno.UI.Toolkit still ships it untrimmed (~246 KB with its .pri and Generic.xbf), which a plain WinUI app doesn't.

On master (7.0) the path is lib/net10.0-windows10.0.19041.0 and the assembly is Uno.UI.Extras.dll. The path now matches the NuGet asset, so it probably links correctly (not verified), but it's still hardcoded to one TFM and will break the same way once a second Windows TFM ships. _UnoIncludeUIToolkit hardcodes the same path for the .pri and the Uno.UI.Toolkit/** assets.

Expected behavior 🎯

A trimmed .NET 10 WinAppSDK app starts, and Uno.UI.Toolkit.dll goes through the linker like any other package assembly.

How to reproduce it (as minimally and precisely as possible) 🔬

  1. Take an Uno app on Uno.Sdk 6.x (WinAppSDK head, net10.0-windows10.0.xxxxx) that uses something from Uno.UI.Toolkit in XAML (e.g. xmlns:toolkit="using:Uno.UI.Toolkit" with toolkit:VisibleBoundsPadding.PaddingMask), so the XAML type info touches its types.
  2. msbuild -restore /p:TargetFramework=net10.0-windows10.0.26100 /p:Configuration=Release /p:Platform=x64 /p:GenerateAppxPackageOnBuild=true (the default pubxml turns on PublishTrimmed).
  3. Install and launch the .msix. It crashes at startup. The packaged Uno.UI.Toolkit.dll is the net9 file, and System.Runtime.dll isn't in the package.

Workaround 🛠️

Save NuGet's own items before Uno swaps them and put them back afterwards. Verified: the trimmed app starts, every page renders, and Uno.UI.Toolkit.dll is linked (243 KB → 135 KB):

<Target Name="SaveNuGetUnoWinUIReferences" BeforeTargets="_UnoRemoveReferences" Condition="'$(IsWinAppSdk)' == 'true' and '$(PkgUno_WinUI)' != ''">
  <ItemGroup>
    <_NuGetUnoWinUIReference Include="@(ReferencePath)" Condition="'%(ReferencePath.NuGetPackageId)' == 'Uno.WinUI'" />
    <_NuGetUnoWinUICopyLocal Include="@(ReferenceCopyLocalPaths)" Condition="'%(ReferenceCopyLocalPaths.NuGetPackageId)' == 'Uno.WinUI'" />
  </ItemGroup>
</Target>

<Target Name="RestoreNuGetUnoWinUIReferences" AfterTargets="_UnoRemoveReferences" Condition="'$(IsWinAppSdk)' == 'true' and '$(PkgUno_WinUI)' != ''">
  <ItemGroup>
    <_UnoNet9Assembly Include="$(PkgUno_WinUI)/lib/net9.0-windows10.0.19041.0/*.dll" />
    <ReferencePath Remove="@(_UnoNet9Assembly)" />
    <ReferenceCopyLocalPaths Remove="@(_UnoNet9Assembly)" />
    <ReferencePath Include="@(_NuGetUnoWinUIReference)" />
    <ReferenceCopyLocalPaths Include="@(_NuGetUnoWinUICopyLocal)" />
  </ItemGroup>
</Target>

(Re-adding @(RuntimeCopyLocalItems) instead doesn't work: the item gets CopyLocal=true, is counted twice, and ReadyToRun fails with MSB4094.)

Suggested fix: stop replacing items NuGet already resolved correctly, or derive the path from the resolved asset / $(TargetFramework) instead of hardcoding a TFM.

Renderer 🎨

  • Skia
  • Native

Affected platforms 📱💻🖥️

Windows App SDK, Build tasks

Uno.Sdk version (and other relevant versions) 📦

Uno.Sdk 6.6.0-dev.196 (Uno.WinUI 6.6.0-dev.1303). The same hardcoded net9 path is in Uno.WinUI 6.7.65 and 6.8.0-dev.130. Microsoft.WindowsAppSDK 1.7.250909003, .NET SDK 10.0.401, net10.0-windows10.0.26100.

IDE version 🧑‍💻

Command-line MSBuild (Visual Studio 18 Insiders build tools); VS "Package and Publish" uses the same pubxml.

Anything else we need to know? 💬

Trimming is the biggest size lever on Windows: in the app where this was found, the x64 package goes from 252 MB to 130 MB installed.

Activity

  1. added
    kind/bug
    triage/untriaged
    area/build
    on Sep 21, 2026
  2. added
    7.0
    on Oct 14, 2026
  3. removed
    triage/untriaged
    7.0
    on Oct 29, 2026
  4. self-assigned this
    on Oct 31, 2026
  5. added a commit that references this issue on Nov 2, 2026
    0030d94
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/buildkind/bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions