在尝试连接到Nuget时,我得到了下面的错误,然后我无法连接:

无法加载源的服务索引 https://api.nuget.org/v3/index.json。 发送请求时发生错误。 无法连接到远程服务器 连接尝试失败,原因是被连接方在一段时间后没有正确响应,或已建立连接 由于连接的主机未能响应68.232.34.200:443而失败

我可以在浏览器上访问https://api.nuget.org/v3/index.json。


当前回答

我删除了%localappdata%/Nuget中的所有内容,并清除了NuGets缓存。

dotnet nuget locals all --clear

重新启动后,Visual studio 2022恢复了我的包。

其他回答

在我的例子中,我只是重新启动docker并工作。

我试图添加一个Azure Artifacts NuGet源。

在这里,我遵循了微软的指示,但有一个关键的疏忽。

我忘记替换/v3/index了。Json和/v2。

如果有人仍然有问题,NuGet答案不工作。下面的答案对我(一家DevOps Azure托管TFS的公司)来说是有效的:登录和退出团队基金会。TFS和VS都报告为已登录,但情况并非如此。不得不辞职——与op描述的症状相同。详情请参阅此答案。

我在Visual Studio 2015上执行Install-Package Modernizr时遇到了类似的问题。我通过以下步骤解决了这个问题:

Download the package from its online source. Go to Tools/NuGet Package Manager/Package Manager Settings. Select Package Sources from the window. Add a new package source by clicking on the + sign. Enter a name and source location by clicking on ... (triple dot) sign. Make sure that only the package source that you've just added is checked. Uncheck all the other package sources. Go to Package Manager Console and type Install-Package Modernizr. Visual Studio 2015 installs the package automatically and creates Scripts and packages folders in your root folder.

我希望同样的解决方案在安装其他包时也能起作用。

我使用VSO/Azure DevOps。

您也可以直接在浏览器中访问提要url。你最终可能会得到这样的回复,这可能会让你的诊断更快:

用户没有使用ms.feed扩展名的许可证。