11
votes

I'm attempting to use Net Core in my mvc application for security policies. Articles I've read said I need to install DependencyInjection which I'm doing through NuGet in VS 2017. I'm getting the following error:

Could not install package 'Microsoft.Extensions.DependencyInjection.Abstractions 2.0.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.5.2', but the package does not contain any assembly references or content files that are compatible with that framework.

Is this version too new for .net 4.5.2? What version should I be using?

2

2 Answers

15
votes

If you check the dependencies you can see it depends on NetStandard 2.0. From this chart you can see that you must be using at .net 4.6.1 to be compatible with NetStandard 2.0.

If you use Microsoft.Extensions.DependencyInjection.Abstractions 1.1.1 that is compatible .NETStandard 1.0 which is compatible with .NET 4.5 or newer.

7
votes

In the package in nuget.com I can see the version 2.0 has a dependency with .Net Standard 2. .Net Standard 2 is compatible with .NET Framework 4.6.1. Also, you must install .Net Core 2 SDK to have .Net Standard 2 as supported platform in Visual Studio. Also, only Visual Studio 2017 Update 3 is supported. So you must use Visual Studio 2017 Update 3 with .Net Core 2 SDK and .Net Framework 4.6.1 as platfform for the project. The simplest option is installing version 1.1.1 of the package.