6

I've tried to publish a nuget package to my GitHub Packages account but in all cases I'm having the 404 error. I've followed as requested on the GitHub's site:

nuget source Add -Name "GitHub" -Source "https://nuget.pkg.github.com/[MyAccount]/index.json" -UserName [MyUserName] -Password GH_TOKEN

It throwed me an error saying to add an api key.

So I created a Personal Access Token and set the api key:

nuget setapikey [MY_PAT_TOKEN] -Source "https://nuget.pkg.github.com/[MyAccount]/index.json"

But when trying to push again I had:

"Your request could not be authenticated by the GitHub Packages service. Please ensure your access token is valid and has the appropriate scopes configured."

So I created another token with the necessary scopes: - read:packages - write:packages - delete:packages - repo

I deleted the source and the api key and started the steps above again, with the new token, but I had the 404 error, saying that the source was not found.

So I've tried a lot of options... changing package name, changing source name, and a bunch of other things, but with the same result.

So I read this on the GitHub's website:

"When you publish a package, by default GitHub Packages uses the package name to determine the GitHub repository containing the package. For example, a package named odata-client would be published to the OWNER/odata-client repository. If you would like to change the repository containing the package, or publish multiple packages to the same repository, you can include the URL to the GitHub repository in the repository field of the package's .nuspec file."

As I'm using .NET Core 3.0 so I changed the csproj including:

<RepositoryUrl>https://nuget.pkg.github.com/[MyAccount]/Common</RepositoryUrl>
<RepositoryType>git</RepositoryType>

But this time I had a 400 (Bad Request)

And I tired some variations for the above url: ending with index.json, ending without index.json, ending with common, etc... But always have Bad Request error.

So I deleted this configurations and tryied again: 404 (Not Found)

I don't know what to do any more. There are someone that can help me with that? What am I doing wrong? It lacks some configuration?

Levi Silveira
  • 63
  • 1
  • 3

3 Answers3

21

I had same issue. For me it was wrong Repository Url in nuget package. I would advise you to check that RepositoryUrl is set and it is a valid url of existing repo.

Vladimir Zotov
  • 571
  • 6
  • 16
3

I have been fixed the same error setting my repository URL:

  <PropertyGroup>
    <!--Others configurations values-->
    <RepositoryUrl>https://github.com/GITUSERNAME/REPOSITORY-PATH**</RepositoryUrl>
  </PropertyGroup>

I am using dotnet core and setting this configuration in .csproj

Ederson
  • 49
  • 5
0

I had the same issue, my solution was to give all "Repo" permissions to the token. PS: my Repo was private

CSharpino
  • 11
  • 2