更新时间: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>
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.