Consuming nuget packages from my Github

This is a short guide on how to consume packages from my Github packages feed. The official docs are here.

Notes:

Method A: Add user-wide using CLI

Run the following command

dotnet new nugetconfig
dotnet nuget add source -n gh-lordmike https://nuget.pkg.github.com/LordMike/index.json -u MyGithubUser -p MyGithubToken

This adds a package source for your user account, and allows you to consume my packages from all projects you have. On Windows, the password is encrypted on disk.

Method B: Add the source to your project(s) only

Much like Method A, it is possible to add a NuGet.Config file to your project only. Nuget will search for additional config files in parent directories, until it finds one.

dotnet new nugetconfig
dotnet nuget add source -n gh-lordmike https://nuget.pkg.github.com/LordMike/index.json --configfile NuGet.Config -u MyGithubUser -p MyGithubToken

Method A/B, note on sharing

If you share the NuGet.Config between mulitple computers, it will likely not work as the password is encrypted. You may choose to store the password in plaintext, to allow others to read it.. It shouldn't be so bad, as the token will only have access to reading packages (... you did only give it that permission, right?).

If desired, append --store-password-in-clear-text to the previous commands.