19

I am trying to use RestSharp in my C# Visual-Studio 2013 project to POST data at a given URL. When i try to install the package via NuGet it gives me the following error:

Installing 'RestSharp 106.1.0'.
Successfully installed 'RestSharp 106.1.0'.
Adding 'RestSharp 106.1.0' to WebApplicationJson.
Uninstalling 'RestSharp 106.1.0'.
Successfully uninstalled 'RestSharp 106.1.0'.
Install failed. Rolling back...
Could not install package 'RestSharp 106.1.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.5', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

As far as I have read in GitHub this is mostly an issue for .NetPortable framework so I am out of ideas. I have also tried to change my framework version to 3.5 but still the same error.

Has anyone encountered a similar issue?

If you need further information please comment.

Noel
  • 384
  • 1
  • 3
  • 16

3 Answers3

37

The latest version, which supports old .NET Framework versions, is 105.2.3.

Install-Package RestSharp -Version 105.2.3

Since the lowest .NET Framework LTE, which supports async methods is 4.5.2, support of legacy framework has been removed in favour of supporting .NET Standard 2.0 (and .NET Framework 4.5.2).

Alexey Zimarev
  • 17,944
  • 2
  • 55
  • 83
14

If anyone encounters this kind of problem in the future. I solved it by installing it via Package Manager Console found in (Tools -> NuGet Package Manager -> Package Manager Console) and running the following command:

  Install-Package RestSharp -Version 103.1.0

Notice that the installation for RestSharp version 106.1.0 always kept failing, so I changed the version to 103.1.0. Hope this helps anyone with a similar issue.

EDIT

Thanks to phuzi in the comments, RestSharp version 106.1.0 requires .Net framework 4.5.2, as for version 103.1.0 no dependencies are listed.

Noel
  • 384
  • 1
  • 3
  • 16
  • 1
    You could have just updated your .net framework version to 4.5.2 – phuzi Dec 05 '17 at 12:58
  • @phuzi I tried from .net framework version 3.5 to 4.5.1 and thought it had nothing to do with it. Does RestSharp version 106.0.1 differ a lot from version 103.1.0? – Noel Dec 05 '17 at 13:01
  • 1
    Not sure how much is different between the versions but looking at (version 106.1.0 on nuget.org)[https://www.nuget.org/packages/RestSharp/106.1.0] shows a framework dependency on 4.5.2. whilst (version 103.1.0)[https://www.nuget.org/packages/RestSharp/103.1.0] shows no dependencies. The change was probably to support .Net Standard 2.0 making it available for .Net Core – phuzi Dec 05 '17 at 13:05
  • @phuzi yeah now i see it and makes sense. I will update the answer cause makes more sense. – Noel Dec 05 '17 at 13:09
  • @phuzi also please edit your comment to fix the links. (Fixed it in answer) – Noel Dec 05 '17 at 13:10
  • unfortunately too long has passed and I'm unable to edit the comment – phuzi Dec 05 '17 at 13:11
  • It is actually mentioned straight on our Github page. – Alexey Zimarev Dec 06 '17 at 12:40
2

This also happens if the name of your project is RestSharp.

KR Akhil
  • 877
  • 3
  • 15
  • 32