如何在 NuGet 包中包含类库的 Xml Docs?

How do you include Xml Docs for a class library in a NuGet package?(如何在 NuGet 包中包含类库的 Xml Docs?)

本文介绍了如何在 NuGet 包中包含类库的 Xml Docs?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为 C# 类库创建一个 NuGet 包,并且我想将生成的 Xml 文档包含在该库中.这是我的 nuspec 文件:

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:

<?xml version="1.0" encoding="utf-8"?>
<package>
  <metadata>
    <id>MyLibrary</id>
    <version>1.0.0.0</version>
    <authors>John Nelson</authors>
    <language>en-US</language>
    <description>A C# class library</description>
  </metadata>
  <files>
    <file src="....uildMyLibrary.dll" target="libNet40" />
    <file src="....uildMyLibrary.xml" target="libNet40" />
  </files>
</package>

当我使用此命令构建包时:

nuget pack MyLibrary.nuspec

它会产生错误.如果我删除该行:

It generates an error. If I remove the line:

<file src="....uildMyLibrary.xml" target="libNet40" />

NuGet.exe 成功创建 nupkg.我什至可以解压缩包,并验证内容是否正确.我究竟做错了什么?xml文件是否应该进入不同的目标目录?

NuGet.exe successfully creates the nupkg. I can even unzip the package, and verify that the contents are correct. What am I doing wrong? Should the xml file go into a different target directory?

推荐答案

问题是我没有检查我正在使用的构建配置的生成 Xml 文档".那个 nuspec 是正确的.

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

这篇关于如何在 NuGet 包中包含类库的 Xml Docs?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:如何在 NuGet 包中包含类库的 Xml Docs?