【问题标题】:Visual Studio - Nuget - Unable to load the service index for sourceVisual Studio - Nuget - 无法加载源的服务索引
【发布时间】:2018-09-21 05:54:18
【问题描述】:

这是我的 NuGet.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
   <packageSources>
      <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
   </packageSources>
   <disabledPackageSources>
      <add key="Microsoft and .NET" value="true" />
   </disabledPackageSources>
</configuration>

现在,在 Visual Studio 中,当我尝试安装“geckofx45”包时,我收到以下错误:

安装包 geckofx45 install-package : 无法加载源 https://api.nuget.org/v3/index.json 的服务索引。 在行:1 字符:1 + 安装包 geckofx45 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Install-Package], 例外 + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

你有什么解决办法吗?

提前谢谢你

【问题讨论】:

  • 这个问题现在怎么样了?你能安装任何nuget包吗?如果没有,请告诉我此问题的最新状态,以及您尝试了什么。
  • 已解决。在 Visual Studio 中,“工具”>>“选项”>>“NuGet 包管理器”>>“包源”,我禁用了“nuget.org”和“microsoftdotnet”,并在控制台模式下执行 install-package geckofx45.nupkg 和它有效
  • 很高兴知道您已解决此问题,能否将您的评论转换为答案?这对阅读此线程并轻松找到答案的其他社区成员很有帮助。谢谢。 :)。

标签: visual-studio nuget nuget-package


【解决方案1】:

Visual Studio - Nuget - 无法加载源的服务索引

这是一个常见错误,我们无法从该错误消息中获得太多有用的信息。我们只能提供此问题的疑难解答。

大多数情况下出现此问题的原因是网络问题或nuget.config中的配置不正确。

为了确定这个问题是否与VS IDE、网络或其他有关,请首先在浏览器中打开nuget服务器的路径https://api.nuget.org/v3/index.json。如果你可以在浏览器中打开它,这个问题可能与 VS IDE/nuget.config 更相关。可以删除%appdata%\Nuget中的nuget.config,然后重启Visual Studio生成新的nuget.config

其次,如果你在浏览器中也打不开,这个问题可能与网络问题有关,你应该检查我们的系统变量或IE浏览器中是否有代理变量http_proxy,我们可以测试一下在具有相同网络的另一台 PC 上。如果您的 PC 中有代理设置,您可以将其删除以进行测试,或者您可以将代理设置添加到 Nuget.Config 文件中。有关详细信息,请参阅此链接:Nuget Config Section & Nuget Proxy Settings。在我们确认我们的 PC 中没有任何代理后,我们应该检查我们的网络是否受到限制。我们可以用不同的网络对其进行测试。

有关更多详细信息,请参阅the same issue

【讨论】:

  • 删除我的 nuget.config,重新打开 VS,然后重新添加我的自定义包源对我有用。
  • 我可以在浏览器上打开https://api.nuget.org/v3/index.json。所以,我删除了nuget.config 并重试。但对我来说没有成功,我仍然有这个问题。
  • 我确认,使用 VS Community 2019,解决方案是取消 nuget.config 文件。
【解决方案2】:
nuget restore 

msbuild /t:restore

两者都不适合我。但是

dotnet restore 

工作完美。试试看

【讨论】:

    【解决方案3】:

    在 Windows 7 上测试

    Step1:打开命令窗口(运行 cmd) Step 2:运行以下命令以启用 TLS 1.2 支持(如果已禁用)(添加 REGISTRY Entries):

    "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 启用/t REG_DWORD /d 1 /f /reg:32 reg add "HKLM\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client" /v 启用 /t REG_DWORD /d 1 /f /reg:64

    【讨论】:

      猜你喜欢
      • 2023-03-22
      • 1970-01-01
      • 1970-01-01
      • 2022-10-17
      • 1970-01-01
      • 1970-01-01
      • 2018-11-29
      • 2022-10-04
      • 1970-01-01
      相关资源
      最近更新 更多