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

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

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


当前回答

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

其他回答

如果您看到如下错误,您可能需要设置Azure Artifacts凭据,请参阅Github链接,您可以通过运行powershell脚本或手动安装凭据提供程序。

error :   Response status code does not indicate success: 401 (Unauthorized).

I had the same error message while scaffolding Identity to my ASP.NET Core MVC project. Since my connection was not behind a proxy, removing/editing proxy configurations didn't make sense. And I didn't want to delete a file or uninstall PMC either. While looking around I realized a "Clear All Nuget Cache(s)" button on Tools --> Options --> NuGet Package Manager --> General. After pressing the button I had to wait for some time for the operation to complete. After that I tried to scaffold the Identity again but it didn't work. Then I decided to restart VS and voila :)

有些开发环境可能既不使用浏览器也不使用代理。

一种解决方案是从nugget(例如https://dotnet.myget.org/F/dotnet-core/api/v3/index.json)下载包到共享目录,然后执行以下操作:

dotnet add package Microsoft.AspNetCore.StaticFiles -s "shared drive:\index.json"

我希望这对你有用。  

当我试图浏览NuGet包时,我得到了同样的错误,以解决以下相同的步骤:

1-转到%appdata%\NuGet\NuGet.config

2-验证该配置中提到的url

3-删除不需要的url

4-重新启动visual studio并检查

这也可能由于身份验证问题而发生,因此您可能需要重新对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安装