17

I'm trying to install a Nuget package that targets .NetStandard 2.0 (Microsoft.Extensions.Logging.Abstractions) into a Net 4.6.1 project in Visual Studio 2015. However, while Frameworks should be compatible, it doesn't quite work:

Install-Package : Could not install package 'Microsoft.Extensions.Logging.Abstractions 2.0.0'. You are trying to 
install this package into a project that targets '.NETFramework,Version=v4.6.1', 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.
At line:1 char:1
+ Install-Package Microsoft.Extensions.Logging.Abstractions

I've followed the steps outlined here: Entity Framework Core 2.0 on .NET 4.6.1

So I have installed package "NETStandard.Library.NETFramework", and added

<PropertyGroup>
  <PackageTargetFallback>netstandard2.0</PackageTargetFallback>
</PropertyGroup>

to the csproj. But, no luck there - still the same issue.

Is there any way to install a NetStandard 2.0 package into my project (without upgrading VS or installing any Net Core targeting packs or such)?

Thanks

Bogey
  • 4,926
  • 4
  • 32
  • 57
  • 1
    I've just seen that this is a VS2015 project - I suspect that's the problem. It works fine from the .NET Core 2.0 SDK, with a Core SDK-style project. – Jon Skeet Oct 17 '17 at 10:52

2 Answers2

11

Referencing .NET Standard 2.0 packages is supported using the following:

There are a still few bugs when consuming .NET Standard 2.0 libraries, especially when mixing .NET Standard < 2.0 and 2.0 libraries but these updates give basic support.

Manuel Fabbri
  • 542
  • 1
  • 7
  • 16
Martin Ullrich
  • 94,744
  • 25
  • 252
  • 217
  • 1
    Thanks Martin. That does answer the question - unfortunately myself can't go down that route as I am on a no-admin machine and can't install eg the VSIX. Bit of a shame .. .Net development used to be so easy, these days it seems you're out in the cold if you can't update your tools constantly – Bogey Oct 18 '17 at 08:13
  • I also needed to install ".NET Core Tools for Visual Studio 2015" https://github.com/dotnet/core/blob/master/release-notes/download-archive.md#net-core-tools-for-visual-studio-2015 – Sergey Slepov Nov 04 '18 at 01:36
  • Thank you for the https:// link. It fixed my VS 2015 Nuget package problem with Azure.Messaging.ServiceBus.7.1.2. Warning: this link downloads dotnet-standard-support-vs2015-2.0.0-win-x86.msi and will install with no feedback. Shows up in Programs and Features as ".NET Standard Support for Visual Studio 2015 (x86)" – Dan Randolph Apr 29 '21 at 22:16
10

Is there any way to install a NetStandard 2.0 package into my project (without upgrading VS or installing any Net Core targeting packs or such)?

I am afraid not. Just like Jon pointed out that the reason for that issue is that you are using Visual Studio 2015.

According to the .NET Standard, .NET Standard 2.0 support .NET Framework 4.6.1 (with .NET Core 2.0 SDK):

enter image description here

So we need install .NET Core 2.0 SDK. And every communication from Microsoft about the preview of .NET Core 2.0 mentions Visual Studio 2017, so I think it's highly recommanded to use Visual Studio 2017 to work with .NET Core 2.0.

Besides, the NuGet package NETStandard.Library.NETFramework is deprecated.

enter image description here

So install a .NetStandard 2.0 Nuget package into a Net 4.6.1 project, I highly recommanded to use Visual Studio 2017 to work with .NET Core 2.0.

Hope this helps.

Leo Liu
  • 71,098
  • 10
  • 114
  • 135
  • Actually, there is a VS 2015 installer for the required targets and NuGet 3.6.0 for VS 2015 supports this. But there are a few bugs still like https://github.com/dotnet/sdk/issues/1539 – Martin Ullrich Oct 18 '17 at 06:22
  • 5
    Thanks Leo, your answer is much appreciated. In case the MSFT in your name gives away you're working for Microsoft, just some feedback: To me as a semi-professional dev (who must use VS in a non-admin environment with only infrequent/packages updates), C# development has become the modern day version of DLL hell. If very simple packages like the abovementioned one have hard-requirements that need constant admin updates of VS, or even the very latest/greatest version of it, something went very wrong imho. I like Net's progression, but compatibility should not be forgotten! – Bogey Oct 18 '17 at 08:18
  • how about adding reference to .netstandard located in C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\netstandard\v4.0_2.0.0.0__cc7b13ffcd2ddd51\netstandard.dll – mko Nov 28 '18 at 15:34