使用自定义源和官方提要还原dotnet [英] dotnet restore with custom source and official feed

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

问题描述

我有自定义的Nuget存储库(\\build\NugetFeed),而且我正在使用nuget.org恢复我的软件包。

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

用于恢复软件包我使用此命令

For restoring packages I use this command

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

但是在我的构建服务器上,我得到了发生以下错误

But on my build server I get the following error

C:\Program Files\dotnet\sdk\2.2.107\NuGet.targets(114,5): error : The local source 'D:\BuildAgent\_work\5\s\https:\api.nuget.org\v3\index.json' doesn't exist. [D:\BuildAgent\_work\5\s\MyCode.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天全站免登陆