36

How do I include the comments that I write above my methods and properties in my nuget package? Ie. So when the library is consumed the user can use intellisense and read what the method is about?

eg. if I have the method

/// <summary> /// This method does such and such /// </summary> public void SomeMethod() { // does something.. } 

Then I want to user to be able to see "This method does such and such" as they type the method.

1

2 Answers 2

44

In Visual Studio, right-click on the project, choose "Properties", then in the Build -> Output section of the Properties page, select the checkbox next to "Documentation file". Leave the file path empty so that it generates the file in the default location, which is where NuGet will expect it to be located.

Alternately, you can add the following to the .csproj file.

<PropertyGroup> <GenerateDocumentationFile>true</GenerateDocumentationFile> </PropertyGroup> 

Personally, I always put the above in a Directory.Build.props file in the root of the solution so that it's applied to all projects (I also put other common settings there like <TargetFramework> etc.).

In previous versions of .NET Core/VisualStudio, a bug caused the checkbox to store an absolute path to the documentation file which was obviously not ideal for teams. The bug is now be fixed as of version 16.9.

Sign up to request clarification or add additional context in comments.

2 Comments

The preview feature was released in Visual Studio 16.9. Now, just check the Build > Output > Documentation file checkbox in the project properties and it will set GenerateDocumentationFile appropriately.
@HolisticDeveloper thanks! I rewrote the answer to reflect the current state of the Visual Studio UI.
20

You have to enable the XML-Documentation when building.

See here

In Project-Properties go to the Build-Tab and select Xml-Documentationfile.

Looks similiar to this

German Version of Visual Studio

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.