Publishing a NuGet package

Get API Key

To publish a project in the nuget.org repository you first have to get an API key. Go to https://www.nuget.org/ and sign in. Click on your user name which is on the upper right, and select API Keys and then on webpage click on Create.

Enter a name for your key, and enter * for Glob pattern, and then click on the Create button. Save your key somewhere because you cannot copy the key again later on. If you return to the API key page, you will need to regenerate the key.

Edit Package Properties

Open project properties in Rider and edit the NuGet section. Make sure you check the “Generate a NuGet package during the build”

some properties are not available in the rider GUI so you might have to edit them using Visual Studio

All the properties are stored in the *.csproj file so you can also edit them in a text editor. You can use the Origam.Service.Core project for reference service-core/Origam.Service.Core.csproj at master · origam/service-core · GitHub

Build the Project and Publish

Next you can build the project. Make sure you switch the configuration to “Release” and press build. When you then open the bin/Release folder you will see the generated *.nuget file.

Now you will need nuget.exe to publish your package. If you don’t have it you can get it here: https://dist.nuget.org/win-x86-commandline/latest/nuget.exe

The package can now be publiched using this command:

nuget push Origam.Service.Core.1.0.0.nupkg oy2edepystx5fzm45guqybyr7vgmfnboudmnxr5e2gsy36as -Source https://api.nuget.org/v3/index.json

where the third argument is your API key.