Brondahl
Brondahl

Reputation: 8547

Include my Nuget README in my Nuget Package

I maintain a few tiny Nuget Packages.

I have a Nuget README file in the git repository, and the .nupkg file is auto-built by VS, based on the "Package" config, stored in the .csproj file.

Whenever I need to release a new versio of the package, I upload the .nupkg file to nuget, in the web UI, and then it asks me for any documentation, at which point I have to manually upload the README file.

Is there any way to put that README file in the .nupkg so that I don't have to manually upload it every time?

Upvotes: 7

Views: 6496

Answers (3)

Brondahl
Brondahl

Reputation: 8547

NuGet have now added support to make this JustWork.

Announcement on the Issue thread: https://github.com/NuGet/Home/issues/6873#issuecomment-833829727 Announcement Blog post: https://devblogs.microsoft.com/nuget/add-a-readme-to-your-nuget-package/

All you need to do is reference the README.md file in the .csproj, using the PackageReadmeFile tag. If the README.md is in the git root (i.e. where GitHub auto-detects it) then it will look like this:

<PackageReadmeFile>README.md</PackageReadmeFile>

Upvotes: 8

ChrisG
ChrisG

Reputation: 126

i do this via the csprj. file. I created a .netstandard project and added a readme.txt.

add following to the x.csproj

<ItemGroup>
  <None Include="readme.txt" pack="true" PackagePath="." />
</ItemGroup>

When installing the nuget the first time the file will be displayed in VS. There is somewhere in the internet a artikel describing the solution, but i cannot find it now.

enter image description here

Here my complete csproj

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFrameworks>netstandard2.0;net471;net35</TargetFrameworks>
   .....
    <FileVersion>1.0.1.11</FileVersion>
    <AssemblyVersion>1.0.1.11</AssemblyVersion>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="NLog" Version="4.7.6" />
  </ItemGroup>
  <ItemGroup>
    <Compile Update="Properties\Resources.Designer.cs">
      <DesignTime>True</DesignTime>
      <AutoGen>True</AutoGen>
      <DependentUpon>Resources.resx</DependentUpon>
    </Compile>
  </ItemGroup>

  <ItemGroup>
    <None Include="readme.txt" pack="true" PackagePath="." />
  </ItemGroup>

  <ItemGroup>
    <EmbeddedResource Update="Properties\Resources.resx">
      <Generator>ResXFileCodeGenerator</Generator>
      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
    </EmbeddedResource>
  </ItemGroup>

</Project>

Upvotes: 3

Mingwei Samuel
Mingwei Samuel

Reputation: 3262

Currently there is not a way to do this, but it is WIP.

The new spec under review: https://github.com/NuGet/Home/wiki/Embedding-and-displaying-NuGet-READMEs
This issue for this feature: https://github.com/NuGet/Home/issues/6873

Upvotes: 2

Related Questions