How do you include Xml Docs for a class library in a NuGet package?

后端 未结 2 1304
梦如初夏
梦如初夏 2020-12-04 18:50

I am creating a NuGet package for a C# class library, and I would like to include generated Xml Documentation with the library. This is my nuspec file:



        
相关标签:
2条回答
  • 2020-12-04 19:18

    In .NET Core/Standard you can do this by editing the project XML file, for example:

    <PropertyGroup>
        <TargetFramework>netstandard2.0</TargetFramework>
        <GenerateDocumentationFile>true</GenerateDocumentationFile>
    </PropertyGroup>
    
    <PropertyGroup>
        <DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
    </PropertyGroup>
    

    This will output the documentation as an XML file next to your output assembly.

    EDIT: As a side note once you enable GenerateDocumentationFile you will probably get lots of warnings on your public methods for not having added full documentation tags. If you want to disable these warnings simply add in the PropertyGroup:

    <NoWarn>$(NoWarn);1591</NoWarn>
    
    0 讨论(0)
  • 2020-12-04 19:22

    The problem was that I didn't check "Generate Xml Documentation" for the build configuration I was using. That nuspec is correct.

    enter image description here

    0 讨论(0)
提交回复
热议问题