NuGet package source on Github - CassiniLaw/KnowledgeBase GitHub Wiki

Sanjel's NuGet package source on Github

A nuget package source is a location where NuGet packages are hosted. Private packages like PrintingLibrary or SanjelData libs are hosted on GitHub.

Creating PAT (personal access token) to read/write packages

In your GitHub account go to

Settings https://github.com/settings/profile

Developer Settings image

Personal access tokens Tokens (classic) image

Generate new token (classic) image

Set name, desired expiration and select write:packages -> read:packages image

Click on Generate Token at the bottom Copy and save your new token (if you lose it, you have to create a new one) image

Configuring Sanjel GitHub package source

Configure nuget.exe

In order to have access on every location is recommended to configure nuget application on your environment PATH.

Open Environment variables image

Either System or User, click on Path and Edit image

Click on New and add the folder path where nuget.exe is located. image image

You can download the latest version of nuget from the following link: Nuget download page

Once you have done the steps above in a terminal (cmd, powershell) Run the following command to add the package source

Replace GITHUB_USER with your GitHub user Replace PERSONAL_ACCESS_TOKEN with the PAT created in a step above

dotnet nuget add source --username GITHUB_USER --password PERSONAL_ACCESS_TOKEN --store-password-in-clear-text --name SanjelGitHub "https://nuget.pkg.github.com/Sanjel-Energy-Services/index.json"

Browsing the packages

Open a Visual Studio application (restart if it was opened) and open a Solution,

Open Manage Nuget Packages and Select package source

image

You can browse and manage all the packages in that source.

Push / update a package

After you make changes to your project, update the package version following this guide: Nuget versioning

Run the following command in a terminal (cmd, powershell): Replace PACKAGE_SOURCE with the package source name in the step above Replace PACKAGE_NAME1.0.1 with the package name with the version wanted Replace PERSONAL_ACCESS_TOKEN token generated in the step above

dotnet nuget push -s PACKAGE_SOURCE PACKAGE_NAME1.0.1.nupkg --api-key PERSONAL_ACCESS_TOKEN

You can manage packages on GitHub using the following link:

Manage packages

Configure CommonLib NuGet Local source (ARCHIVE. just for reference this step is not necessary)

In Visual Studio Open Tools -> Nuget Package Manager -> Package Sources

  • Add New source (+), set a Name and add the path of eServiceMDM\CommonLib, click Update and OK

  • Your CommonLib should have 3rd Party nuget packages