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

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

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


当前回答

我无法解决问题本身,但找到了一种安装包的方法。

只要直接在包管理器控制台中指定nuget.org作为源。

Update-Package -reinstall -Source nuget.org

其他回答

似乎Nuget仍然使用代理脚本地址(对于我们的VPN),即使代理设置被禁用。我删除了脚本地址,它工作。

我在Windows 10中使用docker-compose up命令在Dockerfile中运行RUN dotnet restore时遇到了同样的错误。

我已经尝试了互联网上提供的所有可能的解决方案,也一直在关注这个公开的问题。最后,在花了8个多小时后,通过遵循前面的步骤,我能够解决我的问题。

Uninstall Docker from your system Restart your system Install Docker from this link. Below is the version of my Docker Restart your system Start Docker for Windows, search Docker in the search bar in Windows. Make sure it is running. You should also go to Services.msc and make sure the services Docker Engine and Docker for Windows Service are running. At last, you must check your Nuget.config file from C:\Users\{Username}\AppData\Roaming\NuGet. For me, the content of that file was as below. <?xml version="1.0" encoding="utf-8"?> <configuration> <packageSources> <add key="nuget.org" value="https://api.nuget.org/v3/index.json" /> </packageSources> <packageRestore> <add key="enabled" value="True" /> <add key="automatic" value="True" /> </packageRestore> <bindingRedirects> <add key="skip" value="False" /> </bindingRedirects> <packageManagement> <add key="format" value="0" /> <add key="disabled" value="False" /> </packageManagement> </configuration> Hope this helps.

我通过安装IISCrypto并在命令行上运行来修复这个问题:

IISCryptoCli.exe /template default /reboot

我尝试了这里列出的许多答案,但这些都不能解决问题。最后,我不得不在Windows中的凭据管理器中删除“Windows凭据”下的VSCredentials_xxx条目,并重新启动Visual Studio 2019。

在那之后——在下一次VS启动时——VS终于向我要了代理凭证——在输入它们之后,Visual Studio就可以访问互联网了。

(似乎VS很久以前就存储了我最初提供的代理凭据-但因为在我们公司,他们在强制执行3个月后更改密码-凭据不再有效。)

就我而言,我在不知情的情况下注销了我的工作账户。重新登录我的visual studio帐户解决了这个问题。