Microsoft-ui-xaml: Win32: Packaging bug for control libraries

Created on 19 May 2020  路  9Comments  路  Source: microsoft/microsoft-ui-xaml

Describe the bug
When packacing a custom control library, Generic.xaml isn't included in the lib folder.

Steps to reproduce the bug

  1. Open the attached project: PackagingBug.zip
  2. Build+Pack project
  3. Inspect the package and notice it only includes the .dll and .pri in the lib folder. The .pri file actually references PackagingBug\Themes\Generic.xbf which isn't available either.

Using this custom library won't work as there's no template to get applied.

Expected behavior
Generic.xaml is included (and not the .xbf because that won't allow us to copy the template)

Version Info
3.0.0-preview1.200515.3

NuGet package version:
3.0.0-preview1.200515.3


| Windows 10 version | Saw the problem? |
| :--------------------------------- | :-------------------- |
| Insider Build (xxxxx) | |
| November 2019 Update (18363) | Yes |
| May 2019 Update (18362) | |
| October 2018 Update (17763) | |
| April 2018 Update (17134) | |
| Fall Creators Update (16299) | |
| Creators Update (15063) | |


| Device form factor | Saw the problem? |
| :-------------------- | :------------------- |
| Desktop | Yes |
| Mobile | |
| Xbox | |
| Surface Hub | |
| IoT | |

needs-triage preview3 team-Markup winui3preview

All 9 comments

@fabiant3 @stevenbrix as FYI

Thanks @ranjeshj

You should be able to add this as a workaround to your .csproj or Directory.Build.targets until the fix comes out in the next preview:

<ItemGroup>
   <None Include="$(OutputPath)\$(AssemblyName)\**\*.xbf">
      <Pack>true</Pack>
      <PackagePath>lib\$(TargetFramework)\$(AssemblyName)</PackagePath>
   </None>
</ItemGroup>

@dotMorten does this work for you?

@dotMorten I don't see this happening for WPF projects, and the default UWP class library doesn't even support the Pack target. I figured you were using the MSBuildSdkExtras, and I don't even see this behavior there. Is this a bug or feature request?

I don't see this happening for WPF projects

This is a WinUI Project. Apples and oranges ;-)

... and the default UWP class library doesn't even support the Pack target

But this is an SDK style project that does.

Main issue here: If I create a WinUI .NET 5 control library project, how am I going to package it as a nuget package, if the templates doesn't get added to the package and later applied to the controls at runtime?

With UWP we used to turn on "Create Library Layout" and it would copy the uncompiled template etc to the output folder, and that would be the layout we'd have to pack (manually) into a nuget package.

With UWP we used to turn on "Create Library Layout" and it would copy the uncompiled template etc to the output folder, and that would be the layout we'd have to pack (manually) into a nuget package.

Gotcha, thanks!

This is fixed, but since we don't have designer support, I don't think you'll be able to edit the template anyways. As a workaround you can grab it out of the nuget manually and edit it

@dotMorten I'm assuming that if you're generic.xaml looks like this:

<ResourceDictionary>
  <ResourceDictionary.MergedDictionaries>
     <ResourceDictionary Source="ms-appx://Styles/MyControlStyle.xaml"/>
  </ResourceDictionary.MergedDictionaries>
</ResourceDictionary>

then you need Styles\MyControlStyle.xaml included, yeah?

@stevenbrix That's up to you :-)

I just want to create a control library, use the Pack to generate a nuget package, and users of that nuget package will get the custom controls with the included templates applied correctly, and the ability to override the template by generating a copy of it via the tooling. Whether you merge them into a single file or not I don't think would matter.

I'll give you free rein wrt how to make that actually work :-)

Closing now that preview3 has been released. Please reply if this is incorrect.

Confirmed fixed!

Was this page helpful?
0 / 5 - 0 ratings