我正在开发一个UWP库(这一个),我刚刚将目标版本升级到了16299 SDK。这还导致NuGet引用从project.json文件迁移到.csproj文件作为PackageReference,理论上这听起来非常好。
但是,在尝试发布NuGet包的beta版本(与nuget pack一样通常生成)之后,我注意到库依赖项没有被正确添加,并且我开始得到异常,说明某个给定类型缺失(因为它的依赖项缺失)。
我发现本期实际上证实了nuget pack还不支持PackageReference依赖关系。
我通过跟踪MSBuild尝试使用本指南,并尝试使用:
>msbuild /t:pack UICompositionAnimations.csproj /p:NuspecFile=UICompositionAnimations.nuspec /p:Configuration=Release
但我最后和有不少错误在一起了。
使用NuGet的UWP库使用
PackageReference的正确打包方法是什么?
谢谢你的帮助!
发布于 2018-02-16 12:31:27
如何使用PackageReference打包UWP库?
正如您所知道的,nuget.exe pack目前不支持基于包引用的项目,而且"允许将项目引用DLL添加到nuget.exe中的nuget.exe中的pack目标的父nupkg中“功能正在进行中。
作为解决办法,您可以手动将依赖项包含在.nupsec文件中,下面是我的.nuspec
<?xml version="1.0"?>
<package >
<metadata>
<id>ClassLibrary1</id>
<version>1.0.0</version>
<authors>Tester</authors>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Package description</description>
<releaseNotes>Summary of changes made in this release of the package.</releaseNotes>
<copyright>Copyright 2018</copyright>
<tags>Tag1 Tag2</tags>
<dependencies>
<dependency id="Newtonsoft.Json" version="10.0.3" />
</dependencies>
</metadata>
<files>
<file src="bin\Debug\ClassLibrary1.dll" target="lib\uap10.0"/>
</files>
</package>打包此.nuspec文件后,将使用依赖项Newtonsoft.Json生成包。

有关更多详细信息,请参阅创建UWP包。
希望这能有所帮助。
https://stackoverflow.com/questions/48813509
复制相似问题