在尝试连接到Nuget时,我得到了下面的错误,然后我无法连接:
无法加载源的服务索引 https://api.nuget.org/v3/index.json。 发送请求时发生错误。 无法连接到远程服务器 连接尝试失败,原因是被连接方在一段时间后没有正确响应,或已建立连接 由于连接的主机未能响应68.232.34.200:443而失败
我可以在浏览器上访问https://api.nuget.org/v3/index.json。
在尝试连接到Nuget时,我得到了下面的错误,然后我无法连接:
无法加载源的服务索引 https://api.nuget.org/v3/index.json。 发送请求时发生错误。 无法连接到远程服务器 连接尝试失败,原因是被连接方在一段时间后没有正确响应,或已建立连接 由于连接的主机未能响应68.232.34.200:443而失败
我可以在浏览器上访问https://api.nuget.org/v3/index.json。
当前回答
去
设置(PC全局设置)>网络和Internet >代理>自动代理设置>和“自动检测设置”设置为“关闭”。
其他回答
如果您看到如下错误,您可能需要设置Azure Artifacts凭据,请参阅Github链接,您可以通过运行powershell脚本或手动安装凭据提供程序。
error : Response status code does not indicate success: 401 (Unauthorized).
去
设置(PC全局设置)>网络和Internet >代理>自动代理设置>和“自动检测设置”设置为“关闭”。
我通过安装IISCrypto并在命令行上运行来修复这个问题:
IISCryptoCli.exe /template default /reboot
在我的例子中,问题在于我是在旧的Win7虚拟机上构建的。
我从https://github.com/NuGet/NuGetGallery/issues/8176#issuecomment-683923724找到了这个修复:
nuget.org started enforcing the use of TLS 1.2 (and dropped support for TLS 1.1 and 1.0) earlier this year. Windows 7 has TLS 1.2 disabled by default (check the DisabledByDefault value under HKLM\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client in your registry). To enable the support, please make sure you have an update (*) installed and switch the support on: reg add HKLM\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client" /v DisabledByDefault /t REG_DWORD /d 0 /f /reg:32 reg add "HKLM\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client" /v DisabledByDefault /t REG_DWORD /d 0 /f /reg:64 reg add "HKLM\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client" /v Enabled /t REG_DWORD /d 1 /f /reg:32 reg add "HKLM\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client" /v Enabled /t REG_DWORD /d 1 /f /reg:64
(*)更新指的是Microsoft kb3140245: Windows 7更新(KB3140245)
我安装了更新,重新启动(按照更新的要求),添加了那些注册表项,然后Nuget就可以正常工作了。
有些开发环境可能既不使用浏览器也不使用代理。
一种解决方案是从nugget(例如https://dotnet.myget.org/F/dotnet-core/api/v3/index.json)下载包到共享目录,然后执行以下操作:
dotnet add package Microsoft.AspNetCore.StaticFiles -s "shared drive:\index.json"
我希望这对你有用。