Search code examples
githubnugetgithub-package-registry

Unable to push github package for nuget (404)


I am unable to push a nuget package to GitHub

The following question is nearly identical

Publishing and Consuming GitHub Package Repository with NuGet: Unable to load the service index error

The answer was very helpful as it indicated that the GitHub documentation was out of date. So I followed the revised instructions and still no joy.

I try to push with...

nuget push -source https://nuget.pkg.github.com/mycompany/index.json .\bin\Release\mynugetpackage.1.0.0.nupkg -apikey xxxaaabbb

and the error I get is...

Pushing mynugetpackage.1.0.0.nupkg to 'https://nuget.pkg.github.com/mycompany'...
  PUT https://nuget.pkg.github.com/mycompany/
  NotFound 
https://nuget.pkg.github.com/mycompany/ 471ms

which seems to indicate that the mycompany GitHub package repository does not exist. But the GitHub organization mycompany certainly exists. It seems as though I need to initialize the package repository for mycompany, but I can't find any documentation on how to do that.


Solution

  • The issue is apparently you cannot push packages to repositories that are private. As soon as I turned the visibility on my repository public, I could push a package.

    This seems like a bug. Certainly nowhere in the documentation does this restriction appear.

    You should be able to push packages to private repositories.

    UPDATE

    It turns out the real problem was the scope of my personal access token. The scope was set to read and write packages but repo scope also required to push a package to a private repo.