NuGet 还原从同一组织中的另一个项目的提要失败 404。
当使用管道中的 nuget restore
时,找不到不同项目中的提要。
最佳答案
经过长时间的搜索,这些是使其一致工作所必需的步骤:
设置权限
设置构建管道
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
配置文件
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="feed_name" value="feed_url" />
</packageSources>
</configuration>
无需向管道添加身份验证任务,因为 dotnet 命令会自行执行此操作...但是:
Most dotnet commands, including build, publish, and test include an implicit restore step. This will fail against authenticated feeds, even if you ran a successful dotnet restore in an earlier step, because the earlier step will have cleaned up the credentials it used.
- Source (.NET Core CLI task docs)
关于.net-core - Nuget 还原不适用于 Azure Devops 中的工件源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61384798/