How to include XML documentation file in NuGet package built from a project file?(如何在从项目文件构建的 NuGet 包中包含 XML 文档文件?)
问题描述
我认为将 C# 生成的 XML 文档文件包含在 NuGet 包中与 DLL 一起为消费者提供智能感知文档通常是一种很好的做法.
I consider it generally good practice to include the XML documentation file generated by the C# build in NuGet packages alongside the DLLs to provide intellisense documentation for consumers.
但是,我不清楚在使用 VS 2017 的项目文件格式构建包时如何做到这一点.
However, it's not clear to me how this can be done when building a package using VS 2017's project file format.
这可能吗?
显然我可以切换到维护 nuspec 文件,但是 VS2017 格式非常方便将版本和依赖项保存在一个地方.
Obviously I could switch over to maintaining a nuspec file but the VS2017 format is very convenient for keeping versions and dependencies all in one place.
推荐答案
只要你在你的csproj文件中设置GenerateDocumentationFile
这样:
As long as you set GenerateDocumentationFile
in your csproj file like this:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
</Project>
那么所有默认设置都会在正确的位置生成文档文件,并且会包含在 NuGet 包中.
then all the defaults will generate the documentation file at the correct location and it will be included in the NuGet package.
如果 Visual Studio 添加了 DocumentationFile
或其他元素,您可以将其删除并替换为单个 GenerateDocumentationFile
属性.
If Visual Studio added DocumentationFile
or other elements, you can delete them and replace it with the single GenerateDocumentationFile
property.
这篇关于如何在从项目文件构建的 NuGet 包中包含 XML 文档文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在从项目文件构建的 NuGet 包中包含 XML 文档文件?


- 输入按键事件处理程序 2022-01-01
- 如何用自己压缩一个 IEnumerable 2022-01-01
- C# 中多线程网络服务器的模式 2022-01-01
- C#MongoDB使用Builders查找派生对象 2022-09-04
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- WebMatrix WebSecurity PasswordSalt 2022-01-01
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01