问题
This is my 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>
Now, in Visual Studio, when I try to install 'geckofx45' package, I get the following error :
install-package geckofx45 install-package : Unable to load the service index for source https://api.nuget.org/v3/index.json. At line:1 char:1 + install-package geckofx45 + ~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Install-Package], Exception + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
Do you have any solutions ?
Thank you in advance
回答1:
Visual Studio - Nuget - Unable to load the service index for source
This is a common error, we could not get much useful info from this error message. We could only provide the troubleshootings for this issue.
The reason for this issue in most cases is because the network issue or the incorrect configuration in the nuget.config
.
In order to make sure that whether this issue is related to the VS IDE, the network or others, first, please open the path of the nuget server https://api.nuget.org/v3/index.json
in the browser. If you can open it in the browser, this issue probably more related to the VS IDE/nuget.config. You can delete nuget.config
in the %appdata%\Nuget
, then restart the Visual Studio to generate the new nuget.config
.
Second, if you also could not open it in the browser, this issue probably related to the network issue, you should check if you have proxy variable http_proxy
in our system variables or in the IE browser, we could test it on another PC with same network. if you have the proxy settings in your PC, you can remove it to test it or you can add proxy settings into Nuget.Config file. Refer to this link for details: Nuget Config Section & Nuget Proxy Settings. After we confirm we do not have any proxy in our PC, then we should to check if our network is limited. We could test it with a different net work.
See the same issue for some more details.
回答2:
nuget restore
and
msbuild /t:restore
both didn't work for me. But
dotnet restore
worked perfect. Try that
来源:https://stackoverflow.com/questions/49773500/visual-studio-nuget-unable-to-load-the-service-index-for-source