问题描述
我认为将 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 文档文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!