使用自定义源和官方源进行 dotnet 恢复 [英] dotnet restore with custom source and official feed

查看:36
本文介绍了使用自定义源和官方源进行 dotnet 恢复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有自定义 Nuget 存储库 (\buildNugetFeed),而且我正在使用 nuget.org 来恢复我的包.

I have custom Nuget repository (\buildNugetFeed) and also i'm using nuget.org to restore my packages.

为了恢复包,我使用这个命令

For restoring packages I use this command

dotnet restore --source \buildNugetFeed --source https://api.nuget.org/v3/index.json --verbosity n

但是在我的构建服务器上我收到以下错误

But on my build server I get the following error

C:Program Filesdotnetsdk2.2.107NuGet.targets(114,5): error : The local source 'D:BuildAgent\_work5shttps:api.nuget.orgv3index.json' doesn't exist. [D:BuildAgent\_work5sMyCode.sln]

并且没有恢复来自官方 Nuget 的软件包.是否还有其他使用 dotnet restore 的配置选项?

and no packages from official Nuget is restored. Is there any another config options for using dotnet restore?

推荐答案

好像是 dotnet cli restore 命令错误.

Seems like a dotnet cli restore command error.

如果您先指定本地原点,则会失败,否则会起作用.

It fails if you specify the local origin first, but works otherwise.

# Fails
dotnet restore --source /tmp/Nuget --source https://api.nuget.org/v3/index.json

#Works
dotnet restore --source https://api.nuget.org/v3/index.json --source /tmp/Nuget

无论如何,您始终可以使用自定义 Nuget.config

Anyway, you can always use a custom Nuget.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="nuget.org" value="https://www.nuget.org/api/v3/index.json" />
    <add key="local" value="/tmp/Nuget" />
  </packageSources>
</configuration>

甚至将其添加到项目本身

or even add it to the project itself

 <PropertyGroup>
      <RestoreSources>$(RestoreSources);https://api.nuget.org/v3/index.json;/tmp/Nuget</RestoreSources>
  </PropertyGroup>

这个问题似乎相关.

这篇关于使用自定义源和官方源进行 dotnet 恢复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆