如何在从项目文件构建的NuGet包中包含XML文档文件? [英] How to include XML documentation file in NuGet package built from a project file?

查看:315
本文介绍了如何在从项目文件构建的NuGet包中包含XML文档文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为,将C#生成的XML文档文件与DLL一起包含在NuGet包中,以为消费者提供智能感知文档,通常是一种好习惯.

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文档文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆