Skip to content

[MSAL] Move Uno.WinUI.MSAL to depend on Uno.WinRT only #24066

Open

Description

@kazo0

What would you like to be added? 💡

Move the Uno.WinUI.MSAL add-in to depend on Uno.WinRT only, dropping its Uno.WinUI dependency.

Today the package declares a hard dependency on the full UI framework, even though the add-in's code only consumes the WinRT layer. Follow-up to the review discussion on PR #24055.

Current state

build/nuget/Uno.WinUI.MSAL.nuspec declares <dependency id="Uno.WinUI" …> in every non-Windows TFM group (net9.0, net10.0, and all -android / -ios / -tvos / -maccatalyst groups).

At the project level, however, four of the five heads already reference the WinRT layer only:

Head Uno project reference Layer
Uno.UI.MSAL.Reference.csproj Uno.UWP\Uno.Reference.csproj WinRT ✅
Uno.UI.MSAL.Skia.csproj Uno.UWP\Uno.Reference.csproj WinRT ✅
Uno.UI.MSAL.netcoremobile.csproj Uno.UWP\Uno.netcoremobile.csproj WinRT ✅
Uno.UI.MSAL.Windows.csproj (none — WinAppSDK) n/a ✅
Uno.UI.MSAL.Wasm.csproj Uno.UI\Uno.UI.Wasm.csproj + Uno.UI.Runtime.WebAssembly.csproj UI ❌

The WASM head is the outlier, and nothing in the add-in's source obviously requires the UI layer:

  • ContextHelper.Current (Android branch) resolves to src/Uno.UWP/ContextHelper.cs — the WinRT layer, not Uno.UI.
  • The Apple branch uses UIKit.UIApplication — platform BCL.
  • WasmWebUi.wasm.cs uses [JSImport] from System.Runtime.InteropServices.JavaScript — no Uno.UI type.
  • No Microsoft.UI.Xaml / Windows.UI.Xaml type is referenced anywhere in src/AddIns/Uno.UI.MSAL.

Why is this needed? 🤔

1. The build already has to special-case MSAL because of this.
PR #24055 added uno.ui.msal to the IsWinRTAssembly allow-list in RuntimeAssetsSelectorTask, so its uno-runtime assets follow UnoWinRTRuntimeIdentifier instead of the UI/Skia renderer identifier:

// src/SourceGenerators/Uno.UI.Tasks/RuntimeAssetsSelector/RuntimeAssetsSelectorTask.cs:261
// Uno.UI.MSAL only depends on the WinRT layer (Uno.UWP), so it must follow the
// WinRT layer selection to keep its platform-specific helpers (#20601).
private bool IsWinRTAssembly(string fileNameWithoutExtension)
    => fileNameWithoutExtension.ToLower(CultureInfo.InvariantCulture)
        is "uno" or "uno.ui.dispatching" or "uno.foundation" or "uno.ui.msal";

That is a hardcoded assembly name in a build task compensating for a package dependency that doesn't match the library's actual layering. If the package declared Uno.WinRT, asset selection should resolve correctly out of the box and the special case could be removed.

2. Consumers shouldn't pull the whole UI framework for token acquisition. Non-UI, headless, or service-side consumers currently drag in Uno.WinUI transitively.

3. Layering consistency. It aligns the shipped package graph with what 4 of the 5 heads already do in source.

Renderer 🎨

  • Skia
  • Native

Both are affected: the WASM head's assets serve the native/DOM WASM target and — since #24055 — the Skia-on-WASM target as well.

For which platforms 📱💻🖥️

  • WebAssembly (primary — the only head still referencing Uno.UI)
  • Build tasks (RuntimeAssetsSelectorTask special case)
  • Android, iOS, Desktop (Windows / macOS / X11) (affected by the package-graph change)

Anything else we need to know? 💬

⚠️ Breaking change — targeting 7.0

Consumers who reference Uno.WinUI.MSAL and today receive Uno.WinUI transitively would no longer get it and must reference it explicitly. Uno.WinRT is a subset of what Uno.WinUI brings in, so most app scenarios should keep working, but the package-graph change is observable and can break restore or trimming in edge cases. Because of that, this should not ship in a minor release.

Research needed before implementing

The WASM head's Uno.UI reference may exist for MSBuild reasons rather than C# type usage — this needs to be verified, not assumed:

  • _UnoRequiresEmbeddedResourcesInjection / _UnoInjectedResource is used to embed the TypeScript-compiled MSAL.WebUI.js as Uno.UI.MSAL.WasmScripts.MSAL.WebUI.js. Confirm that mechanism (and the runtime side that loads WasmScripts) does not depend on Uno.UI / Uno.UI.Runtime.WebAssembly being referenced.
  • LinkerDefinition.xml embedding and trimming behavior.

Proposed tasks

  • Audit what Uno.UI.MSAL.Wasm.csproj genuinely needs from Uno.UI / Uno.UI.Runtime.WebAssembly, at both the C# and MSBuild level.
  • If removable, repoint the WASM head at the WinRT-layer projects (Uno.UWP\Uno.Wasm.csproj plus whatever Uno.Foundation runtime pieces the JS interop needs).
  • Update build/nuget/Uno.WinUI.MSAL.nuspec: replace Uno.WinUI with Uno.WinRT in all dependency groups.
  • Remove the uno.ui.msal special case from RuntimeAssetsSelectorTask.IsWinRTAssembly and confirm assets still land in the right place for Skia-WASM, Skia-mobile, and native heads.
  • Clean up the legacy uno.ui.msal NuGet cache-override path in Uno.UI.MSAL.Wasm.csproj (_TargetNugetFolder) if the Uno.UI.MSAL package name is no longer produced.
  • Runtime-validate the src/SamplesApp/SamplesApp.Samples/Msal sample end-to-end (actual token acquisition, not compile-only) on WASM (Skia + native), Skia Desktop, Android, iOS, and WinAppSDK.
  • Verify linker/trimming behavior is unchanged.

Related

Activity

  1. added this to the Platform 7.0 milestone on Aug 13, 2026
  2. added
    kind/enhancement
    area/build
    area/msal
    on Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/buildarea/msalkind/enhancement

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions