{"id":2005,"date":"2021-05-06T12:00:22","date_gmt":"2021-05-06T19:00:22","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/dotnet\/?p=2005"},"modified":"2021-05-06T12:00:22","modified_gmt":"2021-05-06T19:00:22","slug":"add-a-readme-to-your-nuget-package","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/dotnet\/add-a-readme-to-your-nuget-package\/","title":{"rendered":"Add a README to Your NuGet Package"},"content":{"rendered":"<p>In March, we published a blog on the <a href=\"https:\/\/devblogs.microsoft.com\/dotnet\/state-of-the-nuget-ecosystem\/\">State of the NuGet Ecosystem<\/a>, where we discussed insights gained from the hundreds of customers we&#8217;ve heard from over the last six months. One of the top problems customers identified in our surveys is that &#8220;most packages have insufficient docs&#8221; easily accessible from NuGet.org. In fact, 45% of NuGet.org survey respondents reported &#8220;critical packages I need do exist but they are not well documented&#8221; as a reason for dissatisfaction with the NuGet ecosystem.<\/p>\n<p><strong>We&#8217;re excited to announce that you can finally pack a <code>README.md<\/code> file in your NuGet package and have it fully rendered on NuGet.org!<\/strong><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/user-images.githubusercontent.com\/15097183\/117067900-95cc6780-acf8-11eb-8b29-212b70413a14.png\" width=\"1000\" alt=\"Image of README from MySqlConnecter package on NuGet.org\" \/><\/p>\n<p><em>&#8211; Image from <a href=\"https:\/\/www.nuget.org\/packages\/MySqlConnector\/\">MySqlConnector<\/a> package<\/em><\/p>\n<p>This new capability is still in preview with support starting in .NET SDK 5.0.300 preview, NuGet 5.10 preview 2, and Visual Studio 16.10 preview 2. The easiest way to try this feature today is to <a href=\"https:\/\/dotnet.microsoft.com\/download\/dotnet\/6.0\">install the latest .NET 6 preview<\/a> or <a href=\"https:\/\/visualstudio.microsoft.com\/vs\/preview\/\">the latest Visual Studio preview<\/a>.<\/p>\n<p>Previously, we offered limited support for markdown documentation on NuGet.org. However, this experience required authors to paste a link to their README or paste their README contents on NuGet.org for each new package version. We heard from authors that this additional step took too much time and felt removed from the rest of the package creation and publishing process.<\/p>\n<p>In the new experience, you add the <code>README.md<\/code> file the same way you would for any other embedded package file like an icon or license. This means:<\/p>\n<ol>\n<li>You don&#8217;t have to go to NuGet.org just to add documentation to your package, you can do it with whichever tools you prefer to use to author NuGet packages.<\/li>\n<li>Once you set up your project file with a path to your <code>README.md<\/code>, the latest version of your README will be packed every time. Just set it and forget it!<\/li>\n<li>The README file is immutable and version-specific, so consumers can view the relevant README for older versions of the package too!<\/li>\n<\/ol>\n<h2>Add a README to your package<\/h2>\n<p>If you already have a <code>README.md<\/code> file, including it in your package is as easy as adding a couple lines to your project file for <a href=\"https:\/\/docs.microsoft.com\/nuget\/resources\/check-project-format\">SDK-style projects<\/a> or nuspec for non-SDK-style projects. If you are new to <a href=\"https:\/\/docs.microsoft.com\/nuget\/quickstart\/create-and-publish-a-package-using-the-dotnet-cli\">creating NuGet packages<\/a>, we recommend going with an SDK-style project.<\/p>\n<p>For the following examples, I am keeping my <code>README.md<\/code> file in a &#8220;docs&#8221; folder so its relative path to my project file is <code>docs\\README.md<\/code>. You can also use a README file at the repository root or any other folder as long as you use adjust the relative path. Additionally, you can name the target file anything you would like, such as <code>NuGet.md<\/code> instead of <code>README.md<\/code>.<\/p>\n<h3>Add a README in your project file (recommended)<\/h3>\n<p>You can <a href=\"https:\/\/docs.microsoft.com\/nuget\/reference\/msbuild-targets#packagereadmefile\">reference the README in the project file<\/a> as follows:<\/p>\n<pre><code class=\"language-xml\">&lt;Project Sdk=\"Microsoft.NET.Sdk\"&gt;\n    &lt;PropertyGroup&gt;\n        ...\n        &lt;PackageReadmeFile&gt;README.md&lt;\/PackageReadmeFile&gt;\n        ...\n    &lt;\/PropertyGroup&gt;\n\n    &lt;ItemGroup&gt;\n        ...\n        &lt;None Include=\"docs\\README.md\" Pack=\"true\" PackagePath=\"\\\"\/&gt;\n        ...\n    &lt;\/ItemGroup&gt;\n&lt;\/Project&gt;<\/code><\/pre>\n<h3>Add a README in your nuspec<\/h3>\n<p>You can <a href=\"https:\/\/docs.microsoft.com\/nuget\/reference\/nuspec#readme\">reference the same README in the nuspec<\/a> as follows:<\/p>\n<pre><code class=\"language-xml\">&lt;package&gt;\n    &lt;metadata&gt;\n    ...\n    &lt;readme&gt;docs\\README.md&lt;\/readme&gt;\n    ...\n    &lt;\/metadata&gt;\n    &lt;files&gt;\n    ...\n    &lt;file src=\"..\\README.md\" target=\"docs\\\" \/&gt;\n    ...\n    &lt;\/files&gt;\n&lt;\/package&gt;<\/code><\/pre>\n<h2>Writing a README for NuGet.org<\/h2>\n<p>Consider including the following items in your README:<\/p>\n<ul>\n<li>An introduction to what your package is and does &#8211; what problems does it solve?<\/li>\n<li>How to get started with your package &#8211; are there any specific requirements?<\/li>\n<li>Links to more comprehensive documentation if not included in the README itself.<\/li>\n<li>At least a few code snippets\/samples or example images.<\/li>\n<li>Where and how to leave feedback such as link to the project issues, Twitter, bug tracker, or other platform.<\/li>\n<li>How to contribute, if applicable.<\/li>\n<\/ul>\n<p>Keep in mind, high quality READMEs can come in a wide variety of formats, shapes, and sizes! If you already have a package available on NuGet.org, chances are that you already have a <code>README.md<\/code> file in your repository that would be a great addition to your NuGet.org details page.<\/p>\n<h3>Preview your README<\/h3>\n<p>To <a href=\"https:\/\/docs.microsoft.com\/nuget\/nuget-org\/package-readme-on-nuget-org#preview-your-readme\">preview your README file<\/a> before it&#8217;s live on NuGet.org, upload your package using the <a href=\"https:\/\/www.nuget.org\/packages\/manage\/upload\">Upload Package web portal<\/a> on NuGet.org and scroll down to the &#8220;Readme File&#8221; section of the metadata preview. It should look something like this:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/user-images.githubusercontent.com\/15097183\/117218491-4017be00-add1-11eb-9744-e3006fc509b6.png\" width=\"1000\" alt=\"Image of README file preview section of the NuGet.org package upload metadata preview page\" \/><\/p>\n<p>Consider taking time to review and preview your readme file for <a href=\"https:\/\/docs.microsoft.com\/nuget\/nuget-org\/package-readme-on-nuget-org#allowed-domains-for-images-and-badges\">image compliance<\/a> and <a href=\"https:\/\/docs.microsoft.com\/nuget\/nuget-org\/package-readme-on-nuget-org#supported-markdown-features\">supported formatting<\/a> to make sure it gives a great first impression to potential users! To correct mistakes on your package README once it&#8217;s published to NuGet.org, you will need to push an updated package version with the fix. Making sure everything looks good in advance may save you headache down the road.<\/p>\n<h3>Markdown and image support<\/h3>\n<p>NuGet.org READMEs support <a href=\"https:\/\/commonmark.org\/\">CommonMark<\/a> compliant Markdown through the <a href=\"https:\/\/github.com\/lunet-io\/markdig\">Markdig<\/a> parsing engine. See our <a href=\"https:\/\/docs.microsoft.com\/nuget\/nuget-org\/package-readme-on-nuget-org#supported-markdown-features\">NuGet.org README documentation<\/a> for a full list of supported Markdown features.<\/p>\n<p>Due to security and privacy concerns, NuGet.org will only support badges and images from a <a href=\"https:\/\/docs.microsoft.com\/nuget\/nuget-org\/package-readme-on-nuget-org#allowed-domains-for-images-and-badges\">trusted allow-list of sources<\/a>. Unfortunately, links to local images won&#8217;t be supported at this time either. Consider hosting local images in one our trusted sources to produce a link to include in your NuGet.org README.<\/p>\n<h3>Examples<\/h3>\n<p>We want to thank every NuGet.org package author that volunteered to try out the new README experience in advance to give us feedback and serve as models for the broader NuGet ecosystem.<\/p>\n<p>Check out the following NuGet.org packages and how they used READMEs to enhance the richness of their package details page and improve the onboarding experience for new and prospective users:<\/p>\n<ul>\n<li><a href=\"https:\/\/www.nuget.org\/packages\/NLog.Web.AspNetCore\/4.13.0-readme-preview\">NLog.Web.AspNetCore<\/a> by <a href=\"https:\/\/www.nuget.org\/profiles\/304NotModified\">Julian Verdurmen<\/a><\/li>\n<li><a href=\"https:\/\/www.nuget.org\/packages\/GraphQLinq.Client\/\">GraphQLing.Client<\/a> by <a href=\"https:\/\/www.nuget.org\/profiles\/Giorgi\">Giorgi Dalakishvili<\/a><\/li>\n<li><a href=\"https:\/\/www.nuget.org\/packages\/Ben.Demystifier\/\">Ben.Demystifier<\/a> and <a href=\"https:\/\/www.nuget.org\/packages\/Ben.Http\/\">Ben.Http<\/a> by <a href=\"https:\/\/www.nuget.org\/profiles\/ben_a_adams\">Ben Adams<\/a><\/li>\n<li><a href=\"https:\/\/www.nuget.org\/packages\/MySqlConnector\/\">MySqlConnector<\/a> by <a href=\"https:\/\/www.nuget.org\/profiles\/bgrainger\">Bradley Grainger<\/a> and Caleb Lloyed<\/li>\n<li><a href=\"https:\/\/www.nuget.org\/packages\/CommonHelpers\/\">CommonHelpers<\/a> by <a href=\"https:\/\/www.nuget.org\/profiles\/LancelotSoftware\">Lance McCarthy<\/a><\/li>\n<\/ul>\n<h2>Where can I see package READMEs?<\/h2>\n<p>When a package with an embedded README is uploaded to NuGet.org, the README can be found on its <a href=\"https:\/\/docs.microsoft.com\/nuget\/nuget-org\/package-readme-on-nuget-org\">NuGet.org package details page<\/a>. A link to the README will also be available in the Visual Studio package details pane.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/user-images.githubusercontent.com\/15097183\/117067287-d24b9380-acf7-11eb-86e0-0bc4de3ac8a1.png\" width=\"500\" alt=\"Image of the Ben.Demystifier package details pane in Visual Studio that includes a link to their README on NuGet.org\" \/><\/p>\n<p><em>&#8211; Image from <a href=\"https:\/\/www.nuget.org\/packages\/Ben.Demystifier\/\">Ben.Demystifier<\/a> package<\/em><\/p>\n<h2>We want to hear your feedback!<\/h2>\n<p>Your feedback is very important to us. If you experience any problem trying the new README feature, check out our <a href=\"https:\/\/github.com\/NuGet\/Home\/wiki\/Submitting-Bugs-and-Suggestions\">documentation on submitting bugs and suggestions<\/a> to find the right place to look for solutions or file new issues.<\/p>\n<p>To see what is coming to NuGet next, view <a href=\"https:\/\/github.com\/NuGet\/Home\/pulls\">our public proposals<\/a> or <a href=\"https:\/\/github.com\/NuGet\/Home\/blob\/dev\/meta\/README.md\">create your own proposal<\/a>. Be sure to leave your feedback on existing issues &amp; pull requests!<\/p>\n<p>If you add a README to your NuGet.org package, tweet about it and mention <a href=\"https:\/\/twitter.com\/nuget\">@nuget<\/a> to get a like or retweet from us to signal boost your package!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today, we&#8217;re excited to announce that you can pack a `README.md` file in your NuGet package and have it fully rendered on NuGet.org!<\/p>\n","protected":false},"author":24894,"featured_media":58792,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[7933,7874,7931],"tags":[30,104,7848],"class_list":["post-2005","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-feature-announcement","category-nuget","category-nuget-org","tag-announcement","tag-nuget","tag-nuget-org"],"acf":[],"blog_post_summary":"<p>Today, we&#8217;re excited to announce that you can pack a `README.md` file in your NuGet package and have it fully rendered on NuGet.org!<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/2005","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/users\/24894"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/comments?post=2005"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/2005\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media\/58792"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media?parent=2005"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/categories?post=2005"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/tags?post=2005"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}