deployment - 创建多个 Nuspec 文件

标签 deployment nuget nuspec

我目前正在尝试为 this solution 中的所有项目发布大量 nuget 包。 .这些项目设置在一个简单的树中,Myre 是基础项目,一切都依赖于它:

Myre <- Myre.Debugging <- Myre.Debugging.UI <- Myre.UI
Myre <- Myre.UI
Myre <- Myre.Entities <- Myre.Graphics

我正在尝试将每个单独的项目打包为一个 nuget 包,并根据需要对其他 Myre 子项目包具有正确的依赖关系。

我的第一步是为 Myre 制作一个包( nuspecbat file of process )。这似乎工作得很好,图库显示 Myre 具有 ninject(另一个 nuget 包)依赖项,并且一切正常。

当我尝试制作下一个包装时,问题就出现了。 Myre.Debugging取决于 Myre(具有正常的项目引用),仅此而已。使用 this nuspec使用 nuget 包(详细)给出:
Attempting to build package from '(x86) Myre.Debugging.csproj'.
Packing files from 'C:\Long_Path\Myre\Myre.Debugging\bin\x86\Release'.
Add file 'C:\Long_Path\Myre\Myre.Debugging\bin\x86\Release\Myre.Debugging.dll' to package as 'lib\net40-Client\Myre.Debugging.dll'
Add file 'C:\Long_Path\Myre\Myre\bin\x86\Release\Myre.dll' to package as 'lib\net40-Client\Myre.dll'
Add file 'C:\Long_Path\Myre\Myre\bin\x86\Release\Myre.XML' to package as 'lib\net40-Client\Myre.XML'
Found packages.config. Using packages listed as dependencies

Id: Myre.Debugging
Version: 1.0.0.2
Authors: Microsoft
Description: Description
Dependencies: Ninject (= 3.0.1.10)

Added file 'lib\net40-Client\Myre.Debugging.dll'.
Added file 'lib\net40-Client\Myre.dll'.
Added file 'lib\net40-Client\Myre.XML'.

Successfully created package 'C:\Long_Path\Myre\Myre.Debugging\Myre.Debugging.1.0.0.2.nupkg'.

如您所见,它获取了一个 packages.config 文件(大概来自 Myre,因为没有 here ),然后它从中确定 Ninject 依赖项。如果我希望 Myre.Debugging 和 Myre 成为一个包,那就没问题了。然而,这不是我想要的,我希望 Myre.Debugging 获得对 Myre 包的依赖。

如何设置 nuget 以使用 Myre 作为包引用,而不是简单地将 Myre 程序集复制到 Myre.Debugging 包中?

编辑::我尝试不使用 -IncludeReferencedProjects 并指定:
<dependencies>
  <dependency id="Myre" version="1.0.0.1" />
</dependencies>

但出于某种原因,这只是创建了一个完全没有依赖关系的包!即使像这样手动指定依赖项确实有效,也不是很理想。

最佳答案

根据NuGet command line reference for the Pack command , IncludeReferencedProjects开关的工作原理如下:

Include referenced projects either as dependencies or as part of the package. If a referenced project has a corresponding nuspec file that has the same name as the project, then that referenced project is added as a dependency. Otherwise, the referenced project is added as part of the package.



在您的情况下,Myre.Debugging.nuspec与项目文件名不匹配:(x86) Myre.Debugging.csproj等。我怀疑您需要匹配这些文件名才能使该命令行选项起作用。

或者,如果您想让它与 <dependencies> 一起使用nuspec 文件中的元素,您可能会面临名称不匹配问题的另一个变体。您的 Myre.nuspec文件定义其 ID 如下:

<id>$id$</id>



NuSpec reference$id$ token 被替换为“程序集名称”。如果说的是 DLL 的名称(忽略扩展名),那么我认为生成的 ID 将是 (x86) Myre等。您可能想暂时尝试对 ID 进行硬编码,以查看是否能解决问题。

我还没有尝试进行这些建议的更改,我不能保证它们会起作用,但我希望这为您指明了正确的方向。祝你好运!

关于deployment - 创建多个 Nuspec 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20079651/

相关文章:

c# - 添加迁移显示错误 EntityFrameworkCore.Design 未安装

.net - 创建 NuGet 包 : NU5128 exception - not clear on how to fix

nuget - 如何根据 NuGet 中的目标框架指定条件依赖项?

nuget - 如何从 VSTS 中的一个 nuspec 生成发布包和预发布包?

winforms - 使用测试自动化推送部署

angular - 发布 ASP.NET Core 2 Angular 6 SPA 模板应用程序

asp.net - 关于复制与发布网站的问题

git - 使用 Git/Github 部署

package - Sonatype Nexus 缺少 Api key

msbuild - NuGet pack 和 msbuild - 如何将引用程序集打包到另一个位置?