Publishing nuget libraries to Github Packages using paket

Personal Access Token

I’m going to assume that you know how to package a library and have one ready to publish. In order for this process to work you will need a Github Personal Access Token. When you are logged in to Github you can get this from your profile — Settings | Developer Settings | Personal Access Tokens. Create a new token ensuring it has the read:packages and write:packages scope and name it so that you will know what it’s for, you will be using this later.

Packages Url

The next step is to work out the url you need to push to. This is done using the following template

https://nuget.pkg.github.com/[OWNER]/index.json

The big push

The final step is to push using paket. One of the things that’s easy to overlook here, especially for new projects is that the library project file should have the RepositoryUrl specified —

<RepositoryUrl>https://github.com/[OWNER]/MyLibrary.git</RepositoryUrl>
paket push MyPackage.nupkg --url https://nuget.pkg.github.com/[OWNER] --api-key {myPersonalAccessToken]

Update Feb 2021

One of my libraries was randomly throwing errors when I tried to push it

Could not push MyPackage.0.5.0.nupkg: Request to 'https://nuget.pkg.github.com/owner' failed with: 400 BadRequest - {"error":"No destination repository detected. Ensure the source project has a 'RepositoryUrl' property defined. If you're using a nuspec file, ensure that it has a repository element with the required 'type' and 'url' attributes."}
<RepositoryType>git</RepositoryType>

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Steve Ellwood

Steve Ellwood

Senior Integrations Officer at Doncaster Council Any views expressed are entirely my own.