13 Oct 2021

How to publish your project as nuget package

Publishing your project as nuget package can seems difficult for new developers, but it’s really quite simple task. In this article I’ll use my demo repo with simple progress bar for C#, which can be found on GitHub to guide you.


Let’s start with few tips:

  • Establish unique package id
  • Use symver to version your package
  • Include descriptive package summary

Project configuration

Below you can find part of properly configured .csproj file.

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


  <Authors>Krzysztof Begiedza</Authors>
  <Summary>Simple progress bar for your C# console app</Summary>
  <Copyright>Copyright © Krzysztof Begiedza 2021</Copyright>




To add icon for package you can utilize <PackageIcon> tag with image included inside <ItemGroup> tag. NuGet gallery suggests icon with 128x128 px resolution encoded as .png file with transparent background.

    <None Include="../../docs/icon128.png" Pack="true" PackagePath="\"/>

You can combine multiple values inside tags by using semicolon between tags, i.e.:



Finally we can pack our package with dotnet pack -c Release and publish generated .nupkg file directly to NuGet repository. You can upload package manually, use automated pipeline (ex. GitHub Actions) or do it with bash/powerShell script using NuGet API keys.

To publish with CLI you can execute following code:

dotnet nuget push <your-package>.nupkg --api-key <your-API-key> --source https://api.nuget.org/v3/index.json

Further reading

Using this knowledge you can go deep and experiment with:

  1. Signing
  2. NuGet API keys
  3. GitHub NugetPackages
  4. Package prefix registration