Azure 管道中的 dotnet 还原

时间:2021-05-26 14:54:30

标签: azure-pipelines

我需要恢复其他管道产生的包

- task: DotNetCoreCLI@2
  displayName: 'dotnet restore'
  inputs:
    command: 'restore'
    restoreSolution: 'build.sln'
    #feedsToUse: 'select'
    #vstsFeed: 'Some-DLLs'
    # includeNuGetOrg: true
    feedsToUse: 'config'
    nugetConfigPath: 'nuget.config'

nuget.config 在哪里

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <clear />
    <add key="Some-DLLs" value="https://tfs.co.net/tfs/collection/_packaging/Some-DLLs/nuget/v3/index.json" />
  </packageSources>
  <packageSourceCredetials>
    <Some-DLLs>
      <add key="Username" value="DOMAIN\richard.barraclough" />
      <add key="ClearTextPassword" value="un33xgbppqqbeowgwq6b2xn35gkohzbhrz54ohitxefhc5hgjsla" /> <!-- A PAT -->
    </Some-DLLs>
  </packageSourceCredetials>
</configuration>

然而,他的步骤失败了

         C:\Program Files\dotnet\sdk\5.0.104\NuGet.targets(131,5): error : Unable to load the service index for source https://tfs.co.net/tfs/collection/_packaging/Some-DLLs/nuget/v3/index.json. [C:\agent\_work\19\s\build.sln]
       C:\Program Files\dotnet\sdk\5.0.104\NuGet.targets(131,5): error :   No credentials are available in the security package [C:\agent\_work\19\s\build.sln]

这也不起作用

- task: CmdLine@2
  inputs:
    script: 'dotnet restore --configfile nuget.config proj\proj.csproj' 

1 个答案:

答案 0 :(得分:1)

请检查以下事项:

  1. 如果 Artifacts 提要和管道在同一个项目中,您可以使用恢复任务直接将包从提要恢复到管道。

  2. 如果 Artifacts 提要和管道在不同的项目中,但在同一个组织/集合中。

    • 如果提要是项目范围的,您可以打开此提要并导航到“Feed settings”>“Views”>选择“Local” > 点击“Edit” > 选择“All feeds and people in <Your_Collection_Name>”。通过这种方式,同一组织/集合中的所有管道都能够使用从提要下载的包。

    enter image description here

    • 如果提要是组织范围的,您可以使用恢复任务直接将包从提要恢复到管道。
  3. 如果提要在当前组织/集合之外,您需要创建一个 NuGet service connection 来访问提要。

    enter image description here