GitLab package registry Nuget packages per group

Viewed 2737

In my GitLab I have a multiple dotnet core projects (plugins) placed under a group named Plugins, in each one of these projects I added a CI steps to pack them in nuget packages and push them to the GitLab package registry. I followed the documentation : https://docs.gitlab.com/ee/user/packages/nuget_repository/index.html and in the .gitlab-ci.yaml I placed this config :

image: mcr.microsoft.com/dotnet/sdk:5.0

stages:
  - deploy

deploy:
  stage: deploy
  script:
    - dotnet pack -c Release
    - dotnet nuget add source "$CI_SERVER_URL/api/v4/projects/$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
  only:
    - master

but instead of adding a project level source (which is working for me)"$CI_SERVER_URL/api/v4/projects/$CI_PROJECT_ID/packages/nuget/index.json" I replaced it to group level endpoint "$CI_SERVER_URL/api/v4/groups/{group-id}/-/packages/nuget/index.json" with a deploy token for the authentication because I wanted to have one source for all projects under that group, it shows this error each time the nuget cmd try to push the package

error: ERROR: This version of nuget.exe does not support updating packages to package source my-source

any ideas?

2 Answers

I ran into this too. I found this link https://docs.gitlab.com/ee/user/packages/workflows/project_registry.html

The idea suggested in the link is to create a project in the group, the push all your packages to that project. It's not ideal, pushing directly to the group would be nicer, but it is a workaround that doesn't require multiple Nuget sources in Visual Studio. (as of February 2021, hopefully group-level push is supported in the future)

When pushing to project level source packages will also show in group level.

But beware, gitlab has some fundamental problems with nuget integration - if someone does not have access to one project in group, he won't be able to download any packages from that group. So it's much better to create separate project for packages and push/consume packages there.

Related