Publishing nuget libraries to Github Packages using paket

If you’re reading this you are probably aware that you can host your packages on Github. There is plenty of documentation on how to publish to Github packages using Nuget but I have migrated all my libraries to Paket and I wanted to document it so that you can see how simple it is.

Personal Access Token

Packages Url

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

where OWNER is your user name, or your organisation name. You can check the url by browsing to it, you should be asked for a username and password, the username will be your username and the password will be the personal access token, you should get a valid json response

The big push

<RepositoryUrl>https://github.com/[OWNER]/MyLibrary.git</RepositoryUrl>

When I first tried this it still wasn’t happy, but changing the PackageProjectUrl to the same url fixed that, meaning that all I need to do is -

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

and my package is now published.

Github have added a nice touch in that the package has the same visibility as your repo, so private repos have private packages, public repos have public packages.

Update Feb 2021

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."}

I double checked the RepositoryUrl and it was definitely correct. After comparing with a library that was working it became clear that the clue was the type attribute mentioned above and the missing line was

<RepositoryType>git</RepositoryType>

I do find it very odd that this is needed in Github.

--

--

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

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

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