UWP NuGet Package Dependencies
[Updated: 9/15/15 on the NuGet package contents at the end]
In my last post, Targeting .NET Core, I mentioned that NuGet packages targeting .NET Core and using the dotnet
TFM need to list their dependencies. What may not be immediately obvious, as this is new behavior for UWP projects, is that UWP packages need to list their BCL dependencies too, not just “regular” NuGet references.
The reason for this is that UWP projects also use .NET Core and may elect to use newer BCL package versions than the default. While the uap10.0
TFM does imply BCL + Windows Runtime, it doesn’t really say what version of the dependencies you get. Instead, that’s in your project.json
file, which by default includes the Microsoft.NETCore.UniversalWindowsPlatform v5.0.0
“meta-package”, which pulls in most of the .NET Core libraries at a particular version. But what happens if newer BCL packages are published? Right now, the OSS BCL .NET Core packages are being worked on and they’re a higher version – System.Runtime
is 4.0.21-beta*
.
In Windows 8.1 and Windows 8, this wasn’t an issue because those platforms each had a fixed set of BCL references. You’d know for sure what BCL version’s you’d get for each of those. But now with UWP, that’s no longer true, so you need to specify them.
Fortunately, you don’t have to figure out all of the dependencies by hand. Instead, you can use my handy NuSpec.ReferenceGenerator
tool (NuGet|GitHub) to add those dependencies to your NuSpec file.
The ReadMe is fairly detailed, but for the majority of projects, if you have a NuSpec file whose filename matches your project name (like MyAwesomeLibrary.csproj
with a MyAwesomeLibrary.nuspec
sitting somewhere under the .sln
dir), adding the reference should be all you need.
For a UWP Class Library package, you should have the following in your NuSpec:
- A dependency group with the
uap10.0
TFM - In your Project Build options for Release mode, choose “generate library layout”
- Copy the entire directory structure of the output to your
\lib\uap10.0
dir.
I’m not entirely sure we actually need the `.rd.xml` file! I haven’t added it to `Cimbalino.Toolkit` NuGet package and it still seems to work fine! Scott is aware of this, though at this time we have yet to understand if this file is really necessary or not!
Thanks, I’ll update this post once you confirm whether the .rd.xml file is required
From my quick experiments, the .rd.xml file appears to be required if you include the .pri file from the build output (e.g. if you have MyLibrary.* as the file selector). After I removed the .pri file, the .rd.xml file was no longer required.
The reasons why any of this is so remain totally mysterious to me. Is there any documentation of substance available to help understand this? Your blog is the only source of meaningful information I have been able to find so far!