Reputation: 375
I am trying to install Newtonsoft Json (with the package manager console) so that I can use it in my C# console app, but I get this error:
PM> Install-Package Newtonsoft.Json
Install-Package : Unable to find package 'Newtonsoft.Json'
At line:1 char:1
+ Install-Package Newtonsoft.Json
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
Why am I getting this error?
Upvotes: 3
Views: 13390
Reputation: 71
I found the solution here, maybe it can help you. Basically, do this:
First of all, if you have any old version of Newtonsoft.Json, I recommend uninstalling it. For this you can use the NuGet Package Manager for Solution (in Tools)
Then, in the Package Manager Settings add a new package source with name nuget.org and source https://api.nuget.org/v3/index.json
Finally, using the NuGet Package Manager Console, install the latest version of Newtonsoft.Json (the one shown at https://www.newtonsoft.com/json). For example, in my case the latest version is 13.0.1, so I ran the following command in the PM console:
PM> Install-Package Newtonsoft.Json -Version 13.0.1
That's all.
Upvotes: 0
Reputation: 449
I might be just be late to answer, but this is usually caused by the incorrect package source, different packages come from different sources, for example angularJS.core packages comes from nuget.org source so if you search it and you have Microsoft and .NET set as your source, then you wont be able to find it.
To attempt to answer your question, please select the change the source on your your PM console(see attached screenshot) , you might also want to make sure that you point to the correct project(attached screenshot will also guide you on that regard). Or even better just select "All" on your source and you should be good
Upvotes: 1
Reputation: 77896
What if you try to install it from Package manager UI. Right click in your solution/project and select manage nuget package
. In the presented UI search for newtonsoft.json
and install accordingly.
Also make sure your project don't already have it installed. In your project find the file name package.config
and search for an entry named json.net
. If present, delete that line, save the file and then try re-installing again.
Upvotes: 0