Repository navigation
Description
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 tosrc/Uno.UWP/ContextHelper.cs— the WinRT layer, notUno.UI.- The Apple branch uses
UIKit.UIApplication— platform BCL. WasmWebUi.wasm.csuses[JSImport]fromSystem.Runtime.InteropServices.JavaScript— noUno.UItype.- No
Microsoft.UI.Xaml/Windows.UI.Xamltype is referenced anywhere insrc/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 (
RuntimeAssetsSelectorTaskspecial 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/_UnoInjectedResourceis used to embed the TypeScript-compiledMSAL.WebUI.jsasUno.UI.MSAL.WasmScripts.MSAL.WebUI.js. Confirm that mechanism (and the runtime side that loadsWasmScripts) does not depend onUno.UI/Uno.UI.Runtime.WebAssemblybeing referenced.LinkerDefinition.xmlembedding and trimming behavior.
Proposed tasks
- Audit what
Uno.UI.MSAL.Wasm.csprojgenuinely needs fromUno.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.csprojplus whateverUno.Foundationruntime pieces the JS interop needs). - Update
build/nuget/Uno.WinUI.MSAL.nuspec: replaceUno.WinUIwithUno.WinRTin all dependency groups. - Remove the
uno.ui.msalspecial case fromRuntimeAssetsSelectorTask.IsWinRTAssemblyand confirm assets still land in the right place for Skia-WASM, Skia-mobile, and native heads. - Clean up the legacy
uno.ui.msalNuGet cache-override path inUno.UI.MSAL.Wasm.csproj(_TargetNugetFolder) if theUno.UI.MSALpackage name is no longer produced. - Runtime-validate the
src/SamplesApp/SamplesApp.Samples/Msalsample 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
- PR fix(msal): Deploy platform MSAL assets under SkiaRenderer #24055 — review discussion that prompted this
- [Auth] MSAL Platform specific code does not work in SkiaRenderer mode #20601 — MSAL platform-specific code in SkiaRenderer mode
Activity