【问题标题】:How do I locate the "lib" folder in nuget error?如何在 nuget 错误中找到“lib”文件夹?
【发布时间】:2016-01-13 19:57:19
【问题描述】:

参考本帖:Previous Question

我已经尝试了提出的各种解决方案,但“在 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>

powershell 命令行: nuget spec MyProject.csproj(创建 nuspec 文件的外壳,编辑后看起来像上面的示例)

nuget 包 MyProject.csproj -IncludeReferencedProjects (输出样本) 警告:在包“MyAssembly”中发现 11 个问题。

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

我已经尝试了上一个问题中提到的各种 &lt;files /&gt; &lt;dependency /&gt; 修饰符组合,但仍然出现错误。

这个“lib”文件夹指的是哪个文件夹,我怎样才能获得 nuget 期望依赖 dll 驻留的绝对路径(如果路径是它想要的)?

【问题讨论】:

    标签: assembly nuget


    【解决方案1】:

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

    <files>
      <file src="bin\Release\MyAssembly.???" target="lib" />
    </files>
    

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

    【讨论】:

    • 这是答案的一部分,但是,我还将 DLL 添加到项目中的“Lib”文件夹中。然后在构建项目时引用这些 DLL,而不是移动到 bin\debug。一旦我从项目中删除了 DLL,nuget 包就组装好了。添加 部分有助于正确更新目标项目引用。顺便说一句,如果有人不熟悉构建“lib”文件夹的 nuget 包,那么您的 Visual Studio 二进制文件输出文件夹通常是 bin\debug,除非您更改了它。
    • @user3683706 感谢您明确指出lib 确实是bin\debug 而不是名为“lib”的文件夹!
    • 要避免警告WARNING: Description: The assembly 'lib\MyAssembly.???' is placed directly under 'lib' folder. It is recommended that assemblies be placed inside a framework-specific folder.,只需将target="lib"更改为target="lib\net45"(或相应版本)。
    猜你喜欢
    • 1970-01-01
    • 2019-03-31
    • 1970-01-01
    • 2012-08-05
    • 1970-01-01
    • 2018-12-16
    • 1970-01-01
    • 1970-01-01
    • 2014-02-23
    相关资源
    最近更新 更多