Nuget 包无法识别依赖项中的 $version$
因此,之前我们使用 nuspec 文件 (nuget pack myproj.nuspec
) 调用了 nuget pack.nuspec 看起来像这样:
So, previously we called nuget pack with the nuspec file (nuget pack myproj.nuspec
). The nuspec looked something like this:
<package>
<metadata>
<version>$version$</version>
[more properties]
<dependencies>
<dependency id="MySubProj" version="$version$" />
[more explicit dependencies]
</dependencies>
</metadata>
</package>
我将调用切换到 (nuget pack myproj.csproj
) 以便自动生成我们总是过时的显式依赖项.
I switched the call to (nuget pack myproj.csproj
) so our always-outdated explicit dependencies would be auto-generated.
一切都很好,除了现在完成的 nuspec 类似于
Everything works great, except now the finished nuspec is something like
<package>
<metadata>
<version>1.2.3.4</version>
[more properties]
<dependencies>
<dependency id="MySubProj" version="0.0.0.0" />
[more explicit dependencies]
</dependencies>
</metadata>
</package>
虽然 MySubProj 的正确版本也是 1.2.3.4.
While the correct version of MySubProj would also be 1.2.3.4.
更多信息:
- MySubProj 是同一个解决方案中的一个项目
- 它被捆绑到一个单独的 nuget 包中
- MySubProj nuget 包的版本以及捆绑的 dll 的版本是正确的.
我真的不明白我做错了什么,以及为什么在直接使用 nuspec 与 csproj 时它会起作用:/
I don't get what I am doing wrong really and why it would work when using the nuspec directly vs the csproj :/
在将 csproj 与 nuspec(NuGet 3.5 仍然存在)结合使用时,这似乎是一个非常古老的错误......
Seems like a very old bug while using a csproj combined with nuspec (which is still there with NuGet 3.5) ...
实现此功能的一种方法是添加额外的属性
One way of making this working is by adding an extra property
<package>
<metadata>
<version>$version$</version>
[more properties]
<dependencies>
<dependency id="MySubProj" version="$PackageVersion$" />
[more explicit dependencies]
</dependencies>
</metadata>
</package>
然后更新你的命令
NuGet.exe pack myproject.csproj -Version 1.2.3.4 -Properties "PackageVersion=1.2.3.4"
它不是那么干净,但它有效.
It is not that clean, but it works.