uwpazure-pipelinesnuget-packageuwp-xamlnuget-spec

Configure an azure devops pipeline to pack and push a UWP library with components


I am trying to 'publish' (build, nuget pack and push) a UWP library project to a private azure artifact feed using azure pipelines. I am using the classic editor in pipelines, with the following agents:

I can successfully pack the .csproj file but when I install the nuget package and use a component from the library I get this error:

Severity Code Description Project File Line Suppression State Error XDG0062 System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Windows.UI.Xaml.Markup.XamlParseException: XAML parsing failed. at Windows.UI.Xaml.Application.LoadComponent(Object component, Uri resourceLocator, ComponentResourceLocation componentResourceLocation) at DeviceEnumerationAndPairing.Components.SerialDevicePicker..ctor() --- End of inner exception stack trace --- at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean public DevTest MainPage.xaml 14

I think I need to use a .nuspec to tell the NuGet pack to copy the component's .xaml and .xbf files to the .nupkg. I've entered the following into the .nuspec:

<?xml version="1.0" encoding="utf-8"?>
<package>
  <metadata >
    <id>myfeedname.DeviceEnumerationAndPairing</id>
    <version>1.0.2</version>
    <title>DeviceEnumerationAndPairing</title>
    <authors>idldev</authors>
    <owners>idldev</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>Internal uwp library for device enumeration and pairing</description>
    <releaseNotes>Development</releaseNotes>
    <tags>device serial pairing idl idldev</tags>
  </metadata >
  <files>
    <!-- WinMd and IntelliSense -->
    <!-- XAML controls -->
    <file src="..\DeviceEnumerationAndPairing\bin\Release\DeviceEnumerationAndPairing.XML" target="lib\uap10.0"/>
    <file src="..\DeviceEnumerationAndPairing\obj\Release\embed\DeviceEnumerationAndPairing\Components\SerialDevicePicker.xbf" target="lib\uap10.0\Components"/>
    <file src="..\DeviceEnumerationAndPairing\bin\Release\DeviceEnumerationAndPairing\Components\SerialDevicePicker.xaml" target="lib\uap10.0\Components"/>
    <!-- DLLs and resources -->
    <file src="..\DeviceEnumerationAndPairing\bin\Release\DeviceEnumerationAndPairing.dll" target="runtimes\win10-arm\native\DeviceEnumerationAndPairing.dll"/>
    <file src="..\DeviceEnumerationAndPairing\bin\Release\DeviceEnumerationAndPairing.pri" target="runtimes\win10-arm\native\DeviceEnumerationAndPairing.pri"/>
    <file src="..\DeviceEnumerationAndPairing\bin\Release\DeviceEnumerationAndPairing.dll" target="runtimes\win10-x64\native\DeviceEnumerationAndPairing.dll"/>
    <file src="..\DeviceEnumerationAndPairing\bin\Release\DeviceEnumerationAndPairing.pri" target="runtimes\win10-x64\native\DeviceEnumerationAndPairing.pri"/>
    <file src="..\DeviceEnumerationAndPairing\bin\Release\DeviceEnumerationAndPairing.dll" target="runtimes\win10-x86\native\DeviceEnumerationAndPairing.dll"/>
    <file src="..\DeviceEnumerationAndPairing\bin\Release\DeviceEnumerationAndPairing.pri" target="runtimes\win10-x86\native\DeviceEnumerationAndPairing.pri"/>
    </files>
</package>

..but whether I specify using just the .nuspec, or both the .nuspec and the .csproj - in the 'NuGet pack' , I get the following error when I try to install the nuget package:

Severity Code Description Project File Line Suppression State Error NU1202 Package idldev.DeviceEnumerationAndPairing 1.0.1-CI-20200421-150456 is not compatible with uap10.0.18362 (UAP,Version=v10.0.18362). Package idldev.DeviceEnumerationAndPairing 1.0.1-CI-20200421-150456 does not support any target frameworks.

..and for win10-arm, win10-x86...

I think that I need to add a dependency or a .target file? but I'm shooting in the dark a bit. I know there are some questions out there with similar issues, so hope this isn't a duplicate, and that it makes sense. Any help appreciated...


Solution

  • You can check these tips first:

    1.In your step3, you build the solution with any cpu mode while you're trying to pick the assemblies for win10-arm, win10-x86 ...

    Different from building locally in VS, the VS build task in pipeline can't support batch build. So you need to build the solution several times with different platform.

    2.Check the target framework of the source project the Package comes from. You should make sure the Package's target framework supports the project which you want to install the package in. (TargetPlatformVersion and TargetPlatformMinVersion)

    3.Check if you generate the xml document for release configuration. Check the package project's csproj file, does it exist this line ?: <DocumentationFile>bin\Release\xxxx.XML</DocumentationFile>

    4.Here's one detailed document about how to pack uwp package. You can refer to it for more details. According to that, XAML document should be put into Themes folder.