【发布时间】:2020-08-06 15:14:38
【问题描述】:
NuGet 还原失败,来自同一组织中另一个项目的提要。
当使用管道中的nuget restore 时,找不到不同项目中的提要。
【问题讨论】:
标签: .net-core azure-devops nuget azure-pipelines
NuGet 还原失败,来自同一组织中另一个项目的提要。
当使用管道中的nuget restore 时,找不到不同项目中的提要。
【问题讨论】:
标签: .net-core azure-devops nuget azure-pipelines
经过长时间的搜索,这些是使其始终如一地工作的必要步骤:
设置权限
设置构建管道
nuget.config file 并确保签入feedsToUse 设置为'config'
azure-pipelines.yml
- task: DotNetCoreCLI@2
displayName: DotNetCore-Restore
inputs:
command: 'restore'
projects: '$(PathToSolution)'
feedsToUse: 'config'
nugetConfigPath: '$(PathToNugetConfig)/nuget.config'
includeNuGetOrg: true
nuget.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="feed_name" value="feed_url" />
</packageSources>
</configuration>
不需要向管道添加身份验证任务,因为 dotnet 命令自己会这样做......但是:
大多数 dotnet 命令(包括构建、发布和测试)都包含 隐式恢复步骤。这将对经过身份验证的提要失败, 即使您在前面的步骤中成功运行了 dotnet restore, 因为前面的步骤将清理它使用的凭据。
【讨论】:
dotnet add package,正如您在 MS 文档中的最后引用所示。
您可以参考this doc 来设置 Azure Artifacts Credential Provider,以便在各种工具中使用。
【讨论】: