如何在 nuget 错误中找到“lib”文件夹?

use*_*706 5 assembly nuget

参考这个帖子:上一个问题

我已经尝试了所提出的各种解决方案,但“在 lib 文件夹外组装”错误仍然存​​在。

我在其他项目中使用了下面的 nuspec 文件格式,它工作正常,下面是我的 nuspec 文件:

<?xml version="1.0"?>
<package >
  <metadata>
    <id>Workflow.Assembly</id>
    <version>1.0.0.0</version>
    <title>Workflow.Assembly</title>
    <authors>MyAuthor</authors>
    <owners>MyOwner</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>My Description</description>
    <releaseNotes>My Release notes</releaseNotes>
    <copyright>Copyright 2016</copyright>
    <tags>My Tags</tags>
  </metadata>
</package>
Run Code Online (Sandbox Code Playgroud)

powershell 命令行:nuget spec MyProject.csproj(创建 nuspec 文件的 shell,编辑为与上面的示例类似)

nuget pack MyProject.csproj -InincludeReferencedProjects(输出示例)警告:在包“MyAssembly”中发现 11 个问题。

问题:lib 文件夹外的程序集。描述:程序集“content\lib\MyReferenced.dll”不在“lib”文件夹内,因此当包安装到项目中时,不会将其添加为引用。解决方案:如果需要引用,请将其移至“lib”文件夹中。

我已经尝试了上一个问题中提到的各种<files /> <dependency />修饰符组合,但仍然收到错误。

这个“lib”文件夹引用哪个文件夹,如何获得nuget期望依赖的dll所在的绝对路径(如果路径是它想要的)?

And*_*amb 6

将“文件”部分添加到 nuspec,将项目的输出链接到“lib”文件夹。

<files>
  <file src="bin\Release\MyAssembly.???" target="lib" />
</files>
Run Code Online (Sandbox Code Playgroud)

https://docs.nuget.org/create/nuspec-reference

  • 这是答案的一部分,但是,我还将 DLL 添加到了项目中的“Lib”文件夹中。然后,在构建项目时,会引用这些 DLL,但不会将其移至 bin\debug。当我从项目中删除 DLL 后,nuget 包就可以正常组装了。添加 &lt;files/&gt; 部分有助于正确更新目标项目引用。顺便说一句,如果有人不熟悉 nuget 包,则构建“lib”文件夹是您的 Visual Studio 二进制文件输出文件夹,默认情况下通常为 bin\debug,除非您更改了它。 (6认同)
  • @user3683706 感谢您明确指出“lib”实际上是“bin\debug”,而不是名为“lib”的文件夹! (3认同)