【问题标题】:nuget packaging with version parameter and dependencies带有版本参数和依赖项的 nuget 打包
【发布时间】:2017-01-30 21:50:06
【问题描述】:

我在使用 nuget 打包新包时遇到了一个问题,当我通过命令行指定版本时,它会将其应用于包而不是依赖项。即。

NuGet.exe 包 myproject.csproj -版本 3.0.4.3373

使用 nuspec 文件

<?xml version="1.0"?>
<package>
<metadata>
    <id>MyProject</id>
    <version>$version$</version>
    <authors>Me</authors>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>A description.</description>
    <copyright>Copyright 2014</copyright>
    <dependencies>
        <dependency id="My.First.Dependency" version="[$version$]" />
        <dependency id="My.Second.Dependency" version="[$version$]" />
    </dependencies>
</metadata>
</package>

生成一个版本为 3.0.4.3373 的包,但依赖项都写为 1.0.0.0,这不是我想要的。我希望它们是相同的版本。

我在这里做错了什么。我敢肯定我以前有过这个工作。我想我已经为此使用了 nuget.exe 的 2.5 和 2.8。

【问题讨论】:

标签: nuget


【解决方案1】:

在将 csproj 与 nuspec 结合使用时似乎是一个非常古老的错误(在 NuGet 3.5 中仍然存在)...

实现这一点的一种方法是添加一个额外的属性

<?xml version="1.0"?>
<package>
<metadata>
    <id>MyProject</id>
    <version>$version$</version>
    <authors>Me</authors>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>A description.</description>
    <copyright>Copyright 2014</copyright>
    <dependencies>
        <dependency id="My.First.Dependency" version="[$PackageVersion$]" />
        <dependency id="My.Second.Dependency" version="[$PackageVersion$]" />
    </dependencies>
</metadata>
</package>

然后更新你的命令

NuGet.exe pack myproject.csproj -Version 3.0.4.3373 -Properties "PackageVersion=3.0.4.3373"

它不是那么干净,但它有效。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-03-19
    • 2019-08-13
    • 2021-12-18
    • 1970-01-01
    • 2017-08-03
    • 1970-01-01
    • 1970-01-01
    • 2021-12-10
    相关资源
    最近更新 更多