VS2010安装RestSharp

原文地址:https://www.jianshu.com/p/e452aa003dd5

如何为VS2010安装NuGet Package?

由于工作内容,需要使用RestSharp这个库。在安装好NuGet Package Manager之后,以为搜索后就可以安装。不知为何,无法从NuGet中查询在线数据。

 
 

 

换成从命令行Package Manager Console中进行安装,提示如下的错误:

PM> Install-Package RestSharp -Version 105.2.3
The source at All [(Aggregate source)] is unreachable. Falling back to NuGet Local Cache at C:\Users\seewin\AppData\Local\NuGet\Cache
Install-Package : Unable to find version '105.2.3' of package 'RestSharp'.
At line:1 char:1
+ Install-Package RestSharp -Version 105.2.3
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], InvalidOperationException
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand

检查NuGet Package Manager的配置:


 
 

并没有发现什么异常。从网络中搜索了一些资料,给出的答案是Internet存在异常导致。参考https://github.com/NuGet/Home/issues/1325

没找到答案,只能只能通过手动下载RestSharp进行安装。

版本选择

由于VS2010支持的.NET Framework最高版本为v4.0。目前,RestSharp的最新版本需要依赖.NET Framework 4.5.2:


 
 

所以,为VS2010安装依赖时,要选择适当的安装包进行安装。由于不需要任何依赖,这里选择105.2.3这个版本进行安装:
https://www.nuget.org/packages/RestSharp/105.2.3

安装RestSharp

1、从NuGet下载RestSharp安装包:


 
 

2、将安装包放到默认的本地目录:C:\Users\seewin\AppData\Local\NuGet\Cache


 
 

3、重新打开Package Manager Console,执行以下命令:

PM> Install-Package RestSharp -Version 105.2.3

PM> Install-Package RestSharp -Version 105.2.3
The source at All [(Aggregate source)] is unreachable. Falling back to NuGet Local Cache at C:\Users\seewin\AppData\Local\NuGet\Cache
Installing 'RestSharp 105.2.3'.
Successfully installed 'RestSharp 105.2.3'.
Adding 'RestSharp 105.2.3' to iDiary.
Successfully added 'RestSharp 105.2.3' to iDiary.

4、查看项目依赖引用:


 
 

OK,RestSharp安装成功。



作者:辛未
链接:https://www.jianshu.com/p/e452aa003dd5
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
posted @ 2021-11-08 10:51  lizhigang  阅读(860)  评论(0编辑  收藏  举报