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, choose Origam as the package owner 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 https://github.com/origam/service-core/blob/master/Origam.Service.Core.csproj

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.

Publish from console

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 published 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.

Publish from nuget.org

Alternatively you can go to nuget.org, sign in there and upload the *.nupkg package to the upload page: NuGet Gallery | Sign In

remember to select the Origam organization as the packege owner after uploading the file.

Publish Locally for Debugging

When developing a nuget package you can publish the package locally like this:

add Origam.Service.Core.1.0.0.nupkg -Source "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\"

There are four elements assosiated with the version in the *.csproj file. Make sure you change all of them when you change the package version. The elements are: <AssemblyVersion>, <FileVersion>, <PackageVersion>, <Version>