更新时间:2021-12-13 10:46:20
content
子目录仅用于 packages.config
项目.
The content
subdirectory is only used for packages.config
projects.
使用 PackageReference
样式的 NuGet 引用的项目使用 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>
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.