kuskmen
kuskmen

Reputation: 3775

How to add documentation to NuGet 4.x+ package using VS2017?

I've read guide here, but I couldn't find how to add my generated on build xml documentation file. We used to reference files in old .nuspec files <file></file> tag, but I can't find the equivalent of it.

From what I understood, it seems that if I create xml file on build it should automatically be added to NuGet, but when I examine my nuget after downloading it, it is still without xml documentation.

What I am doing wrong?

EDIT 1

  <PropertyGroup>
    <VersionPrefix>1.0.5</VersionPrefix>
    <PackageVersion>1.0.5</PackageVersion>
    <TargetFrameworks>netcoreapp1.1;net461</TargetFrameworks>
    <AssemblyName>SBTech.ApiUtils</AssemblyName>
    <PackageId>SBTech.ApiUtils</PackageId>
    <GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
    <GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
    <GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
    <OutputPath>bin\Debug\</OutputPath>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Dev|AnyCPU'">
    <OutputPath>bin\Dev\</OutputPath>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Staging|AnyCPU'">
    <OutputPath>bin\Staging\</OutputPath>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
    <OutputPath>bin\Release\</OutputPath>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net461|AnyCPU'">
    <DocumentationFile>bin\Debug\net461\SBTech.ApiUtils.xml</DocumentationFile>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net461|AnyCPU'">
    <DocumentationFile>bin\Release\net461\SBTech.ApiUtils.xml</DocumentationFile>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Staging|net461|AnyCPU'">
    <DocumentationFile>bin\Staging\net461\SBTech.ApiUtils.xml</DocumentationFile>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Dev|net461|AnyCPU'">
    <DocumentationFile>bin\Dev\net461\SBTech.ApiUtils.xml</DocumentationFile>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|netcoreapp1.1|AnyCPU'">
    <DocumentationFile>bin\Debug\netcoreapp1.1\SBTech.ApiUtils.xml</DocumentationFile>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|netcoreapp1.1|AnyCPU'">
    <DocumentationFile>bin\Release\netcoreapp1.1\SBTech.ApiUtils.xml</DocumentationFile>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Staging|netcoreapp1.1|AnyCPU'">
    <DocumentationFile>bin\Staging\netcoreapp1.1\SBTech.ApiUtils.xml</DocumentationFile>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Dev|netcoreapp1.1|AnyCPU'">
    <DocumentationFile>bin\Dev\netcoreapp1.1\SBTech.ApiUtils.xml</DocumentationFile>
  </PropertyGroup>

This adds xml files to my packages, however when I inspect the code of the package from within the client project xml documentation is not shown in VS.

Upvotes: 0

Views: 142

Answers (1)

Martin Ullrich
Martin Ullrich

Reputation: 100581

Once you update to VS 2017 version 15.3 or higher and the .NET Core 2.0.0 SDK ("CLI") - or mono 5.2 on macOS / linux - this will be done automatically once the csproj is set to generate the xml documentation (via the GenerateDocumentationFile property being set to true).

Specifically, this has been fixed as part of this pull request for NuGet 4.3.0

Upvotes: 1

Related Questions