tixovoxi tixovoxi - 1 month ago 25
C# Question

How can I add my UserControl to my NugetPackage?

I have published a simple nuget package that includes an UserControl, but when I install my nuget package it says my usercontrol is not found.

If I change the properties for my usercontrol to Embedded Resource I can't even see my usercontrol.

Well, the question is: How can I implement a UserControl.cs and xaml for a nuget package that is made for UWP project?

Answer

If you're creating a class library with a simple user control, you'll have these files as build output.

Build output

WinRT specific files like .xbf have been around since Windows 8 and .xr.xml since Windows 8.1 and have to be included in your NuGet package as well.

Some files (.dll, .pdb and .pri) go under the lib/uap10.0 folder, while others (.xbf and .xr.xml) go under a subfolder with the name of your assembly.

NuGet package structure

You can either write the nuspec yourself, use the NuGet Package Explorer to create it or any other 3rd party tool.