且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

安装该软件包时,我的nuget软件包中的content文件夹未将文件添加到根目录中

更新时间:2021-10-02 09:30:01

content子目录仅用于packages.config项目.

使用NuGet引用的PackageReference样式的项目改用contentFiles部分,该部分允许指定要使用的生成操作.这些文件不会复制到项目中,而是作为项目中的项目包含在内,并且可以选择设置为复制到使用项目的生成输出中:

Projects using the PackageReference style of NuGet references use the contentFiles section instead which allows to specify the build action to use. Those files aren't copied to the project, but are included as items in the project and optionally set to copy to the consuming project's build output:

<package>
  <metadata>
    ...
    <contentFiles>
        <files include="appsettings.json" buildAction="Content" copyToOutput="true" />
    </contentFiles>
  </metadata>
  <files>...</files>
</package>

请参见 contentFiles文档以获取更多详细信息.

See the contentFiles documentation for more detail.

请注意,这些文件不会复制到项目中,但会以逻辑方式包含在内.只有packages.config项目支持此操作,因为没有其他方法可以贡献文件了-文档还指出这些文件无论如何都应该被认为是不可变的.

Note that those files aren't copied to the project but included logically. Only packages.config projects support this since there was no other way to contribute files - the documentation also states that these files should have been considered immutable anyway.