代码之家  ›  专栏  ›  技术社区  ›  SuperJMN

Nuget包未将.dll.config文件复制到输出文件夹

  •  0
  • SuperJMN  · 技术社区  · 3 年前

    我的nuget包适用于需要配置文件的库( ClassLibrary1.dll.config ). 我试着把它捆成这样:

    enter image description here

    这是 nuspec 文件

    <?xml version="1.0" encoding="utf-8"?>
    <package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
      <metadata>
        <id>ClassLibrary1</id>
        <version>1.0.0</version>
        <authors>ClassLibrary1</authors>
        <owners></owners>
        <requireLicenseAcceptance>false</requireLicenseAcceptance>
        <description>Package Description</description>
        <dependencies>
          <group targetFramework="net5.0" />
        </dependencies>
      </metadata>
      <files>
        <file src="lib\net5.0\ClassLibrary1.dll" target="lib\net5.0\ClassLibrary1.dll" />
        <file src="lib\net5.0\ClassLibrary1.dll.config" target="lib\net5.0\ClassLibrary1.dll.config" />
      </files>
    </package>
    

    我有一个应用程序引用了这个Nuget包。程序集已正确复制到输出文件夹,但 .dll.config 不是。

    这是输出文件夹:

    enter image description here

    发生了什么?我应该怎么做才能将配置复制到输出目录?

    我正在使用Nuget 5.10+

    顺便说一句,我已经阅读了这篇文章的答案,但没有一个有效:

    How can i make dll.config to be part of Nuget package

    0 回复  |  直到 3 年前
        1
  •  0
  •   decocijo    3 年前

    看见 https://stackoverflow.com/a/70608349/487503 对我有用的东西。

    简而言之:将.props和.targets文件添加到在使用nuget包的项目中执行的nuget包中,并将.config文件复制到输出目录。