NuGet包尝试在所有已配置的NuGet源中检索

编程入门 行业动态 更新时间:2024-10-23 07:25:39
本文介绍了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" value="www.nuget/api/v2/" /> <add key="nuget_org" value="api.nuget/v3/index.json" /> <add key="customfeed" value="www.myget/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 api.nuget/v3-flatcontainer/newtonsoft.json/10.0.3/newtonsoft.json.10.0.3.nupkg OK api.nuget/v3-flatcontainer/newtonsoft.json/10.0.3/newtonsoft.json.10.0.3.nupkg 169ms Installing Newtonsoft.Json 10.0.3. GET www.myget/F/sample-feed-edge/api/v3/flatcontainer/newtonsoft.json/10.0.3/newtonsoft.json.10.0.3.nupkg NotFound www.myget/F/sample-feed-edge/api/v3/flatcontainer/newtonsoft.json/10.0.3/newtonsoft.json.10.0.3.nupkg 316ms GET www.nuget/api/v2/Packages(Id='Newtonsoft.Json',Version='10.0.3') OK www.nuget/api/v2/Packages(Id='Newtonsoft.Json',Version='10.0.3') 324ms GET www.nuget/api/v2/package/Newtonsoft.Json/10.0.3 OK www.nuget/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 api.nuget/v3/index.json www.nuget/api/v2/ www.myget/F/sample-feed-edge/api/v3/index.json C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\ Installed: 1 package(s) to packages.config projects

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

我的问题是,

为什么NuGet客户端会尝试在所有配置源中检索?
  • 这是来自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)

    请在此建议解决方案。

    谢谢, Ganesan R。

    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 NuGetwillthe all the sources at the same time, then receive thequickest 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", thiserror infomationwill 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源中检索

    本文发布于:2023-11-02 14:53:15,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1552691.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:NuGet

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!