首页 > 解决方案 > 在 Azure DevOps 服务器中使用私有 Azure 工件中的包

问题描述

我正在使用 Azure DevOps On-Prem(版本 Dev17.M153.3)并且我有 2 个项目。假设第一个是'A',第二个是'B'

PS:我正在使用我自己的构建代理。

一个项目没有任何依赖。 B 项目依赖于A 项目

我为A 项目创建了一个构建管道,然后我从私有 Azure Artifacts 发布了包。现在我需要在我的B 项目的构建管道中使用这个包。

我的提要权限如下;

在此处输入图像描述

我的B 项目从 NuGet 管理器中引用了 A 项目。但是当我尝试完成构建时,我在恢复时遇到了错误。

从 vstsFeed 开始尝试 :(

- task: DotNetCoreCLI@2
  inputs:
    command: 'restore'
    projects: '**/src/**/*.csproj'
    feedsToUse: 'select'
    vstsFeed: '/ea7b2012-c3d3-40e5-80da-487d4013a34f' 

从 Nuget.config 文件第二次尝试

- task: DotNetCoreCLI@2
  inputs:
    command: 'restore'
    projects: '**/src/**/*.csproj'
    feedsToUse: config
    nugetConfigPath: '$(Build.SourcesDirectory)/src/Naf.Core.Repository/NuGet.config'
    includeNuGetOrg: true

两者都不起作用,我收到了这个错误

Restoring packages for .NETCoreApp,Version=v3.1...
           GET https://api.nuget.org/v3-flatcontainer/naf.models/index.json
     1>C:\Azure-Nuevo-Build\_tool\dotnet\sdk\3.1.201\NuGet.targets(124,5): error : Unable to load the service index for source https://xxx.xxxx.com:1234/prj/_packaging/29371197-8dc0-72e7-b8e9-233be25307e3/nuget/v3/index.json. [C:\XXX-XXX-XXX\3\s\src\Naf.Core.Repository\Naf.Core.Repository.csproj]
C:\Azure-Nuevo-Build\_tool\dotnet\sdk\3.1.201\NuGet.targets(124,5): error :   No credentials are available in the security package [C:\XXX-XXX-XXX\3\s\src\Naf.Core.Repository\Naf.Core.Repository.csproj]
         NuGet.Protocol.Core.Types.FatalProtocolException: Unable to load the service index for source https://xxx.xxxx.com:1234/prj/_packaging/29371197-8dc0-72e7-b8e9-233be25307e3/nuget/v3/index.json.
          ---> System.ComponentModel.Win32Exception (0x8009030E): No credentials are available in the security package

我猜它说不能从管道访问提要。

任何想法来解决这个问题。

在 Azure DevOps Cloud 解决方案中,当您切换“将作业授权范围限制为当前项目”时,它可以工作。但在 Azure DevOps Server (on-prem) 中,该选项不可用。根据这个问题

标签: azure-pipelinesazure-artifactsbuild-agentazure-devops-self-hosted-agentazure-devops-server

解决方案


尝试使用custom命令恢复软件包,看看它是否对您有帮助:

- task: DotNetCoreCLI@2
  displayName: 'dotnet custom'
  inputs:
    command: custom
    projects: '**/*.csproj'
    custom: restore
    arguments: '--force'
    vstsFeed: '/ea7b2012-c3d3-40e5-80da-487d4013a34f'

推荐阅读