Reputation:
We are trying to install Microsoft.AspNet.WebApi.Client
in a project that's targeting .NET Framework 4.0
. Unfortunately the servers we are working on don't support .NET Framework 4.5.
When using Nuget Package Manager Console
with the Install-Package
command we are receiving the following error,
PM> install-package Microsoft.AspNet.WebApi.Client
Installing 'Microsoft.AspNet.WebApi.Client 5.1.1'.
.
.
.
Install-Package : Could not install package 'Microsoft.AspNet.WebApi.Client 5.1.1'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.0', 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.
How do we choose the right .NET framework is there a command-line argument where we can mention the .NET version?
Thanks,
Upvotes: 3
Views: 2774
Reputation: 233347
You can't select the .NET version, but you can select the version of the NuGet package:
PM> Install-Package Microsoft.AspNet.WebApi.Client -Version <package version>
So what you'd need to do is to figure out which version was the latest version that supported .NET 4.0. IIRC, it was 4.0.30506.
So, to install version 4.0.30506, you use the command
PM> Install-Package Microsoft.AspNet.WebApi.Client -Version 4.0.30506
Some NuGet packages can contain builds for various different .NET versions (e.g. .NET 3.5, .NET 4, .NET 4.5, etc.), but ASP.NET Web API 2 only supports .NET 4.5.
ASP.NET Web API version 4.0.30506, on the other hand, corresponds to ASP.NET Web API 1, and IIRC it runs on .NET 4.0.
Upvotes: 3