NuGet包尝试在所有已配置的NuGet源中检索 [英] NuGet package try to retrieve in all configured NuGet sources

查看:294
本文介绍了NuGet包尝试在所有已配置的NuGet源中检索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

Hi all,

在NuGet包管理器中安装NuGet包并在VS2017中配置了多个NuGet包源时,NuGet客户端尝试在所有已配置的NuGet
源中检索包并返回消息如"未找到"。

While installing the NuGet packages from the NuGet package manager with configured multiple NuGet package sources in VS2017, the NuGet client try to retrieve the package in all the configured NuGet sources and return the message like "Not Found".

例如:

我在NuGet.Config中配置了以下NuGet源,

For Example:
I have configured the below NuGet sources in my NuGet.Config,

<packageSources> <add key="nuget.org" value="https://www.nuget.org/api/v2/" /> <add key="nuget_org" value="https://api.nuget.org/v3/index.json" /> <add key="customfeed" value="https://www.myget.org/F/sample-feed-edge/api/v3/index.json" /> </packageSources>








我试图  恢复  
Newtonsoft.Json NuGet包从命令提示符处使用" ;
nuget restore "
命令。将尝试NuGet客户端从我的自定义NuGet  Feed中检索Newtonsoft.Json NuGet包,该Feed不包含Newtonsoft.Json NuGet包,并在输出中返回NotFound NuGet包消息。请
查看以下日志,

C:\Users\admin.nuget>nuget restore C:\Users\admin\source\repos\App4\App4.sln
MSBuild auto-detection: using msbuild version '15.4.8.50001' from 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\bin'.
Restoring NuGet package Newtonsoft.Json.10.0.3.
GET https://api.nuget.org/v3-flatcontainer/newtonsoft.json/10.0.3/newtonsoft.json.10.0.3.nupkg
OK https://api.nuget.org/v3-flatcontainer/newtonsoft.json/10.0.3/newtonsoft.json.10.0.3.nupkg 169ms
Installing Newtonsoft.Json 10.0.3.
GET https://www.myget.org/F/sample-feed-edge/api/v3/flatcontainer/newtonsoft.json/10.0.3/newtonsoft.json.10.0.3.nupkg
NotFound https://www.myget.org/F/sample-feed-edge/api/v3/flatcontainer/newtonsoft.json/10.0.3/newtonsoft.json.10.0.3.nupkg 316ms
GET https://www.nuget.org/api/v2/Packages(Id='Newtonsoft.Json',Version='10.0.3')
OK https://www.nuget.org/api/v2/Packages(Id='Newtonsoft.Json',Version='10.0.3') 324ms
GET https://www.nuget.org/api/v2/package/Newtonsoft.Json/10.0.3
OK https://www.nuget.org/api/v2/package/Newtonsoft.Json/10.0.3 1005ms
Adding package 'Newtonsoft.Json.10.0.3' to folder 'C:\Users\admin\source\repos\App4\packages'
Added package 'Newtonsoft.Json.10.0.3' to folder 'C:\Users\admin\source\repos\App4\packages'
Restoring packages for C:\Users\admin\source\repos\App4\App4\App4.UWP\project.json...
Committing restore...
Generating MSBuild file C:\Users\admin\source\repos\App4\App4\App4.UWP\App4.UWP.nuget.props.
Generating MSBuild file C:\Users\admin\source\repos\App4\App4\App4.UWP\App4.UWP.nuget.targets.
Writing lock file to disk. Path: C:\Users\admin\source\repos\App4\App4\App4.UWP\project.lock.json
Restore completed in 13.09 sec for C:\Users\admin\source\repos\App4\App4\App4.UWP\App4.UWP.csproj.

NuGet Config files used:
C:\Users\admin\AppData\Roaming\NuGet\NuGet.Config
C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config

Feeds used:
C:\Users\admin.nuget\packages
https://api.nuget.org/v3/index.json
https://www.nuget.org/api/v2/
https://www.myget.org/F/sample-feed-edge/api/v3/index.json
C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\

Installed:
1 package(s) to packages.config projects








然而,包装完全恢复,没有问题。但是为什么包搜索
所有已配置的源和打印未找到错误,即使它在第一个NuGet源中找到。 

我的问题是,


    < li style ="">为什么NuGet客户端会尝试在所有配置源中检索?
  1. 这是来自NuGet的错误吗?


我使用过Visual Studio 2017(15.4)和NuGet包管理器(4.4.0)

I have used the Visual Studio 2017 (15.4) and NuGet package Manager (4.4.0)

请在此建议解决方案。

谢谢,

Thanks,
Ganesan R.

推荐答案

您好GaneshRengasamy,

Hi GaneshRengasamy,

感谢您在此处发帖。

>>> 1.为什么NuGet客户端尝试在所有配置中检索来源? 2.这是NuGet的错误吗?

>>>1.Why NuGet client try to retrieve in all configures sources? 2.Is this the bug from NuGet?

不,这是NuGet 3.0及更高版本的默认行为。使用较旧的NuGet 2,按顺序搜索包源,但使用NuGet 3及更高版本,它们并行尝试
所以NuGet会同时关注所有来源,然后收到最快的回复,我 为了提高搜索效率。
在这种情况下,您可能会得到两个"package
未找到错误"的日志。和"在第一个NuGet源中找到"。虽然,您收到错误"未找到包",但此错误信息  最终不会出现
结果,除非所有搜索结果都是假的。

No, this is the default behavior for NuGet 3.0 and above. With older NuGet 2 the package sources were searched in order but with NuGet 3 and above they are tried in parallel. So NuGet will the all the sources at the same time, then receive the quickest response, in order to improve search efficiency. In this case, you may get that two logs which "package not found error" and "found in first NuGet source". Although, you get the error "package not found", this error infomation will not eventually appear in the results, unless all the search results are false.

如果您不希望NuGet搜索所有来源,您可以禁用您不想要的那个通过在%appdata%\NuGet中配置nugget.config文件进行搜索:

If you do not want NuGet search all the sources, you can disable the one you do not want to search by configure the nugget.config file in the %appdata%\NuGet:

  <disabledPackageSources>
    <add key="customfeed" value="true" />
  </disabledPackageSources>

希望这会有所帮助。

Hope this helps.


这篇关于NuGet包尝试在所有已配置的NuGet源中检索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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