问题
I was trying to add package through nuget package manager=> package manager console and from Manage Nuget packages from solution directly. I am trying to install Newtonsoft.Json
from Package Manager Like this Install-Package Newtonsoft.Json
but unable to find from the source i.e
Name: nuget.org
Source: https://api.nuget.org/v3/index.json
This gives me result like this:
PM> Install-Package Newtonsoft.Json
Install-Package : Unable to find package 'Newtonsoft.Json' at source ''.
At line:1 char:1
+ Install-Package Newtonsoft.Json
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
Time Elapsed: 00:01:30.2571879
I think that the source
here is blank. May be because of that it is unable to load packages. I have tried to manage the package manager setting but not been able to connect. My package manager setting is like this:
Despite of having good connection of internet I am not been able to install package. My questions are:
- How should I install package?
- What am I doing wrong to install package?
回答1:
Assuming you are using Windows OS Have you initialised vs 2017 after installation or Have you updated your vs 2017?
- If not then please initialized it.
- Restart your PC.
- Open your project in vs 2017
Check your nuget package manager settings.
Name:nuget.org
Source:api.nuget.org/v3/index.json
Now, run nuget package manager from tools=>Nuget Package Manager=>Package Manager Console
and write your install-package command or run Manage nuget package manager for solution from tools=>Nuget Package Manager=>
Hope,it helps you.
回答2:
Your VS 2017 is probably using some kind of proxy setting which is preventing it from accessing the internet.
To check if VS can access internet try opening any web page from within VS Browser. If you cannot browse then my hunch is correct.
Solve the proxy issue and you should be fine.
Hope it helps.
回答3:
I resolved this issue by adding nuget.org
which was missing in my package source.
Go to Tools>
Nuget
package manager>Package Sources>
Click Plus sign >
Name: nuget.org
Source : https://api.nuget.org/v3/index.json
Now your Visual studio will be connected to Internet and package will be downloaded successfully.
来源:https://stackoverflow.com/questions/45050008/visual-studio-2017-professional-unable-to-find-package-at-source