【问题标题】:NuGet does not add dependencies to packageNuGet 不向包添加依赖项
【发布时间】:2017-08-18 22:12:17
【问题描述】:

我正在尝试使用 NuGet pack 命令打包我的 WPF 应用程序。到目前为止,我发现添加 -IncludeReferencedProjects 可以解决引用项目没有打包的问题。

./nuget.exe pack {path}.csproj -NonInteractive -OutputDirectory C:\test -Properties Configuration=release -version 0.1.0 -Verbosity Detailed -IncludeReferencedProjects

我面临的问题是项目的依赖项没有打包。但是,它们确实显示在日志中,如下所示。依赖:EntityFramework。

但从不将依赖项添加到包中。即使我手动检查或部署包,也只部署了 Data.dll{name}.exe

我已经尝试过的(通过搜索 Google/SO):

  • 为 csproj 文件添加 NuSpec 文件
  • NuGet.config 引用正确的包文件夹(以防 NuGet 找不到它)

编辑:添加生成的 .nuspec

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
    <metadata>
        <id>{path}.UpgradeDatabase</id>
        <version>0.1.4</version>
        <title>{path}.UpgradeDatabase</title>
        <authors>stephanbisschop</authors>
        <owners>stephanbisschop</owners>
        <requireLicenseAcceptance>false</requireLicenseAcceptance>
        <description>Description</description>
        <copyright>Copyright ©  2016</copyright>
        <dependencies>
            <dependency id="EntityFramework" version="6.1.3" />
        </dependencies>
    </metadata>
</package>

提前谢谢你, 斯蒂芬

【问题讨论】:

  • 你能显示 nuspec 文件吗?这通常是要走的路。
  • 顺便说一下,有几个选项可以指定依赖关系;您可以按版本或文件添加它们,但这取决于您要如何处理它们。你可以在这里阅读:docs.microsoft.com/en-us/nuget/schema/nuspec
  • 我使用 nuspec xml 和 nuget 包浏览器屏幕截图编辑了我的帖子。
  • 嗯,依赖不是静态添加到包中的。在我看来,如果你运行 install-package 命令,它也会安装依赖项。这还不够吗?
  • 问题是当我们部署这个包时,我们只得到:lib -> net461 -> data.dll 和 {file}.exe。所以 NuGet 在部署后不知道要安装什么。

标签: wpf dependencies nuget nuget-package


【解决方案1】:

问题解决了。 不是我的 NuGet 包缺少依赖项。是 Octopus Deploy 没有恢复包。我们通过在适当的 .NuSpec 文件中添加条目来修复它。现在所有的 .dll、.config 等文件都与包一起打包。

【讨论】:

    猜你喜欢
    • 2012-04-05
    • 2021-03-11
    • 1970-01-01
    • 2020-06-16
    • 2019-03-19
    • 2021-04-02
    • 1970-01-01
    • 2019-11-19
    • 1970-01-01
    相关资源
    最近更新 更多