在尝试连接到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。
当前回答
这也可能由于身份验证问题而发生,因此您可能需要重新对Visual Studio进行身份验证。
在这种情况下,只需在包所在的文件夹中运行以下命令。配置文件的位置(通常是项目的根目录):
dotnet restore --interactive
系统将提示您从浏览器访问配对URL并输入配对代码,例如:
要登录,请使用网络浏览器打开页面https://microsoft.com/devicelogin,并输入代码C2DEJ87H到 身份验证。
这需要.NET CLI,它包含在.NET Core SDK中,可以从https://learn.microsoft.com/en-us/dotnet/core/install/windows安装
其他回答
你需要在Nuget中添加代理设置。配置文件。有关详细信息,请参阅此链接:Nuget配置部分和Nuget代理设置。
删除% AppData % \ \ NuGet \ NuGet徘徊。配置和重新启动VS2019对我来说很有效。
类似于https://github.com/NuGet/Home/issues/3281
在我的情况下,发生这种情况是因为我没有互联网连接,它正在试图搭建
当我试图在本地托管的Gitlab实例中设置NuGet包时遇到了这个错误。错误提示401未经授权的代码。解决方案是用以下方法去除有害源:
nuget source Remove -Name SOURCE_NAME
然后添加相同的源,但这次在命令中指定用户名和密码:
nuget source Add -Name SOURCE_NAME -Source SOURCE_URL -UserName GITLAB_DEPLOY_TOKEN_USERNAME -Password GITLAB_DEPLOY_TOKEN
我在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.