Creating a NuGet package for a .net standard library via dotnet cli

Following on from my last post about Creating a .net standard library via dotnet cli you will get to a point where you are ready to share your library with the world (or your company teammates). Once your testing is complete you need to add a little bit of NuGet information to your project's .csproj file as shown here.

    <Authors>Wes Shaddix</Authors>

Adding the above information to your .csproj file will give NuGet the necessary metadata for others to find and use your library.

Next you need to package up your library's code into a proper .nupkg file. You can do so by running the following from your terminal while in the same folder as your .csproj file.

dotnet pack -c Release -o pkg

This will create a nuget package in the \pkg folder. Next you can upload it to by signing in and using their web ui or you can upload it via the dotnet cli as shown below.

cd pkg
dotnet nuget push <your package>.nupkg -s <nuget server> -k <api key>

This will push the nuget package to the nuget server where it will be available for everyone else to find and use.