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

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

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


当前回答

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

其他回答

我有这个错误,然后我意识到我是用我的个人微软帐户而不是我的工作帐户登录的。

希望这能有所帮助。

你需要在Nuget中添加代理设置。配置文件。有关详细信息,请参阅此链接:Nuget配置部分和Nuget代理设置。

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

我在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.

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

那些说要删除Nuget的答案。如果您正在使用自定义提要,Config将不起作用。如果您正在使用自定义提要,则需要编辑Nuget。配置文件指向自定义提要的索引。