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 –
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.
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
- In your Project Build options for Release mode, choose “generate library layout”
- Copy the entire directory structure of the output to your