首页 > 解决方案 > 在 Azure 上的 nuget 还原步骤中来自特定包源的 Nuget 包

问题描述

我要恢复的包同时nuget.org位于3rd party myget. 第 3 方是我想使用的更高版本(预发布),但它似乎甚至没有尝试找到这个包的 myget 源,因为它在 nuget.org 上找到了包,除了我想要的版本之外以下错误消息:

##[error]The nuget command failed with exit code(1) and error(Errors in packages.config projects
Unable to find version '2.0.0-dev-00013' of package 'Discord.Addons.Interactive'.
  https://api.nuget.org/v3/index.json: Package 'Discord.Addons.Interactive.2.0.0-dev-00013' is not found on source 'https://api.nuget.org/v3/index.json'.)

myget 在我的 nuget.config 中正确配置,它位于我的解决方案根目录中

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
    <add key="Foxbot" value="https://www.myget.org/F/foxbot-discord-addons/api/v3/index.json" />
  </packageSources>
</configuration>

我将如何让 nuget 恢复步骤尊重这个包的 myget 包源?

标签: azure-devopsnugetnuget-package-restore

解决方案


我将如何让 nuget 恢复步骤尊重这个包的 myget 包源?

对于nuget restore任务,有一个选项用于控制在包还原期间使用哪些提要。

查看要使用的提要

在此处输入图像描述

与本地恢复包不同,解决方案目录(Devops Repos)中的文件在我们检查该选项nuget.config之前将不起作用。Feeds in my Nuget.config

所以在这个过程中,nuget 实际上没有使用你的nuget.config文件package source,这导致了这个问题:

在此处输入图像描述

解决方法:

像下面这样配置提要,Nuget.config以确保 nuget 将使用您Nuget.config在解决方案目录中的文件:

在此处输入图像描述

另外:如果你使用的是yaml格式而不是经典格式,你应该设置feedsToUse: 'config'nugetConfigPath: 'path/NuGet.config'


推荐阅读