有没有办法通过 NugGet 和本机库支持快照?

Is there a way to support snapshots with NugGet and native libraries?

我们使用 Visual Studio 编写和维护本机 Windows 应用程序。我们正在研究使用 NuGet 来处理我们的依赖项,它由本机静态库组成。

经过一些研究,我设法使用 NuGet、package.config 和 CoApp PowerShell 脚本来创建和使用其中包含本机库的 NuGet 包。我们现在面临的问题是我们需要有快照支持。

NuGet 3 及更高版本支持的翻转 PreRelease 机制(带有 * 表示版本翻转)看起来很棒,但是,它似乎只适用于 project.json 而不适用于 package.config。 Project.json,但是,似乎不适用于本机包,因为它们没有安装在本地解决方案文件夹中,因此构建找不到 headers 和库。

问题归结为:

编辑:

最后,我们决定使用 Maven 进行依赖管理,因为 NuGet 似乎不支持我们的用例。我大约两周前提交了一个问题,但没有收到任何回复。但是,如果我们决定在我们的用例中强制使用 NuGet,Wendy 提出的解决方案可能是可行的方法,所以我接受它。

有两种方法可以将内容文件添加到使用 project.json 文件的项目中。一个是 "contentFiles" 节点,另一个是 nuspec 文件中的 "files" 节点。详细步骤请参考:

http://blog.nuget.org/20160126/nuget-contentFiles-demystified.html

但请注意,这些方式仅支持 UWP 和便携式 class 库。

This feature is only for packages that will be installed to projects that are managed using a project.json file. Currently only two projects types are managed by a project.json.

1.UWP apps

2.Portable class libraries

The contentFiles option is not available for other project types

如果您正在使用.NET Core 应用程序或其他使用project.json 的类型项目,目前不支持将nuget 包中的内容文件添加到项目中。