Publishing NuGet package in CI/CD fails with 404

I used the official example for my deploy stage:

deploy:
  stage: deploy
  script:
    - dotnet pack -c Release
    - dotnet nuget add source "${CI_API_V4_URL}/${CI_PROJECT_ID}/packages/nuget/index.json" --name gitlab --username gitlab-ci-token --password $CI_JOB_TOKEN --store-password-in-clear-text
    - dotnet nuget push "**/bin/Release/*.nupkg" --source gitlab

But the stage failed with “Unable to load the service index for source” when trying to load the index.json.

I am also unable to push via CLI, but have enabled the packages in the settings.
grafik

An example project can be found here Test Project until beeing removed.

There is/was an error in the gitlab example for CI/CD with NuGet packages. The command should look like following:

dotnet nuget add source "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/nuget/index.json" --name gitlab --username gitlab-ci-token --password $CI_JOB_TOKEN --store-password-in-clear-text
1 Like