Unable to install Newtonsoft Json

蹲街弑〆低调 提交于 2020-01-03 21:11:24

问题


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?


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/38296006/unable-to-install-newtonsoft-json

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!