GitLab 包注册表每组 Nuget 包

GitLab package registry Nuget packages per group

在我的 GitLab 中,我有多个 dotnet 核心项目(插件)放置在名为 Plugins 的组下,在这些项目中的每一个中,我都添加了一个 CI 步骤来将它们打包到 nuget 包中并将它们推送到 GitLab 包注册表。我遵循了文档:https://docs.gitlab.com/ee/user/packages/nuget_repository/index.html 并在 .gitlab-ci.yaml 中放置了这个配置:

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

但不是添加项目级源(这对我有用)"$CI_SERVER_URL/api/v4/projects/$CI_PROJECT_ID/packages/nuget/index.json" 我用用于身份验证的部署令牌将其替换为组级端点 "$CI_SERVER_URL/api/v4/groups/{group-id}/-/packages/nuget/index.json",因为我想为该组下的所有项目提供一个源,每次 nuget cmd 尝试推送包时它都会显示此错误

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

有什么想法吗?

我运行也喜欢这个。我找到了这个 link https://docs.gitlab.com/ee/user/packages/workflows/project_registry.html

link中建议的想法是在组中创建一个项目,将所有包推送到该项目。这并不理想,直接推送到组会更好,但这是一种不需要 Visual Studio 中的多个 Nuget 源的解决方法。 (截至2021年2月,希望以后支持群组级推送)

推送到项目级别时,源包也会显示在组级别。

但请注意,gitlab 在 nuget 集成方面存在一些基本问题 - 如果某人无法访问组中的一个项目,他将无法从该组下载任何包。 因此,最好为包和 push/consume 包创建单独的项目。