Quantcast
Channel: Active questions tagged nuget-package - Stack Overflow
Viewing all articles
Browse latest Browse all 3067

Install NuGet package from GitHub Package Registry

$
0
0

After a lot of trial and error I eventually got my NuGet package on the Github package registry with the following actions/commands:

  1. Go to GitHub
    • Click your avatar (top-right) → Settings → Developer settings → Personal access tokens
    • Generate a token with following scopes: write:packages, read:packages, delete:packages
    • This will automatically check the repo scope for your OAuth token
  2. Open cmd
    • Navigate to your project directory or the directory containing your NuGet package
    • Add a new nuget source
      • dotnet nuget add source --username [GithubUserName] --password [YourApiKey] --name github https://nuget.pkg.github.com/[UsernameOrOrganizationName]/index.json
    • Push the package to the github source
      • dotnet nuget push --source github bin\Release\MyAwesomePackage.1.0.0.nupkg

I can see my NuGet package on GitHub, so now I want to install it.

  1. I created a new project → Manage NuGet packages → Settings
  2. Add package source:

Now I should be able to install my package. But when I select my source and browse for packages, a GitHub login window pops up. And even when I login with my user account credentials, I still can't access my packages (pushed to an organization Github). Now when I use the NuGet package manager for my custom package source I always get the following error in the Output Window:

Error occurs while browsing for packages from custom GitHub source in NuGet package manager

[source-name] Failed to retrieve metadata from source 'https://nuget.pkg.github.com/[UsernameOrOrganizationname]/query?q=&skip=0&take=26&prerelease=true&semVerLevel=2.0.0'.  Response status code does not indicate success: 401 (Unauthorized).

The packages pushed to the GitHub registry should be public, and even with my user account I can't access them for installation. However they appear on my organization's GitHub page.Also the other users shouldn't have to add my personal GitHub package source, but rather the package should appear in some global GitHub feed inside the package manager, not?

What am I doing wrong?


Viewing all articles
Browse latest Browse all 3067

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>