Repository navigation
Description
Current behavior 🐛
When a class library sets GenerateLibraryLayout=true and targets a 4-part Windows TFM (net10.0-windows10.0.19041.0), dotnet pack/msbuild -t:Pack produces two lib/ folders for the Windows target:
lib/net10.0-windows10.0.19041.0/MyLib/Assets/hello.json <-- content only, no assembly
lib/net10.0-windows10.0.19041/MyLib.dll <-- where NuGet puts the assembly
lib/net10.0-windows10.0.19041/MyLib.pri
lib/net10.0/MyLib.dll
lib/net10.0/MyLib.uprimarker
lib/net10.0/MyLib/Assets/hello.json
NuGet normalizes the 4-part TFM when it places the assembly (net10.0-windows10.0.19041, trailing .0 dropped). The layout target that adds the library content uses the raw $(TargetFramework) string, so the content ends up in a different, assembly-less folder. The package installs fine, but the content for the Windows TFM is not next to the assembly where NuGet resolves it, and anything walking lib/<tfm>/ for that TFM will miss it (this was noticed on Lottie assets in a theme library).
Expected behavior 🎯
All files for the Windows TFM live in the same lib/ folder as its assembly (lib/net10.0-windows10.0.19041/...), the same way they do when the project uses the 3-part TFM.
How to reproduce it (as minimally and precisely as possible) 🔬
- Install Visual Studio (full
MSBuild.exeis required,dotnet packrefuses a WinUI library with XAML, UNOB0008) and add aglobal.jsonpointing at the dev Uno SDK:with the Uno dev feed ({ "msbuild-sdks": { "Uno.Sdk.Private": "7.0.0-dev.1432" } }https://uno-platform.pkgs.visualstudio.com/Uno%20Platform/_packaging/unoplatformdev/nuget/v3/index.json) innuget.config. - Create
MyLib/MyLib.csproj:<Project Sdk="Uno.Sdk.Private"> <PropertyGroup> <TargetFrameworks>net10.0;net10.0-windows10.0.19041.0</TargetFrameworks> <OutputType>Library</OutputType> <GenerateLibraryLayout>true</GenerateLibraryLayout> <PackageId>MyLib</PackageId> <Version>1.0.0</Version> </PropertyGroup> <ItemGroup> <Content Include="Assets\hello.json" /> </ItemGroup> </Project>
- Add
Assets/hello.json(content{}), aC.cswithnamespace MyLib; public class C { }, and aTheme.xamlResourceDictionary(any XAML, so the WinUI packaging path runs). - Run
MSBuild.exe MyLib.csproj -restore -t:Pack -p:Configuration=Release -p:IsPackable=true. - List the
lib/entries ofbin/Release/MyLib.1.0.0.nupkg. You get the two Windows folders shown above. - Change the TFM to
net10.0-windows10.0.19041(3-part) and repeat: a singlelib/net10.0-windows10.0.19041/folder with the DLL,.priandAssets/hello.json.
(Side note from the repro: with the 10.0.401 SDK WinRT.Runtime conflicts needed -p:WindowsSdkPackageVersion=10.0.19041.87 to compile. That is unrelated to the packaging behavior.)
Workaround 🛠️
Use the 3-part TFM net10.0-windows10.0.19041 instead of net10.0-windows10.0.19041.0.
Renderer 🎨
N/A (packaging only; affects the Windows / WinAppSDK target)
Affected platforms 📱💻🖥️
Windows (WinAppSDK TFM, SDKIdentifier == Windows)
Uno.Sdk version (and other relevant versions) 📦
Uno.Sdk.Private 7.0.0-dev.1432, .NET SDK 10.0.401, MSBuild from Visual Studio 18 Insiders. Source references are at master commit 47267e7.
IDE version 🧑💻
Command line (MSBuild.exe), Visual Studio 18 Insiders installed.
Anything else we need to know? 💬
Root cause: the Windows branch of the layout target builds the package path from the raw TFM string:
uno/build/nuget/uno.winui.winappsdk.targets
Lines 97 to 105 in 47267e7
| <Target Name="_UnoSdkIncludeWindowsLibraryLayoutItems" | |
| DependsOnTargets="PrepareLibraryLayout" | |
| Condition="'$(GenerateLibraryLayout)' == 'true' AND '$(SDKIdentifier)' == 'Windows' AND '$(_ExtrasSdkHasDesktopAppSupport)'==''"> | |
| <ItemGroup> | |
| <TfmSpecificPackageFile Include="@(_LayoutFile)" | |
| Condition="'$(ProjectName)' == '%(_LayoutFile.ProjectName)'" | |
| PackagePath="lib\$(TargetFramework)\%(_LayoutFile.TargetPath)"/> | |
| </ItemGroup> | |
| </Target> |
<TfmSpecificPackageFile Include="@(_LayoutFile)"
Condition="'$(ProjectName)' == '%(_LayoutFile.ProjectName)'"
PackagePath="lib\$(TargetFramework)\%(_LayoutFile.TargetPath)"/>Suggested fix: compute the folder the same way NuGet does (drop the trailing .0 of a 4-part Windows platform version) instead of using $(TargetFramework) verbatim. The non-Windows branch in uno.ui.tasks.assets.targets (_UnoIncludeLibraryAssets) builds its path from $(TargetFramework) + the platform version too, so it is worth a look while there.
Activity