简体   繁体   English

将 .NetStandard 2.0 Nuget 包安装到 VS2015 Net 4.6.1 项目中

[英]Installing a .NetStandard 2.0 Nuget package into a VS2015 Net 4.6.1 project

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:我正在尝试将面向 .NetStandard 2.0 (Microsoft.Extensions.Logging.Abstractions) 的 Nuget 包安装到 Visual Studio 2015 中的 Net 4.6.1 项目中。但是,虽然框架应该是兼容的,但它并不完全有效:

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我已按照此处概述的步骤操作: Entity Framework Core 2.0 on .NET 4.6.1

So I have installed package "NETStandard.Library.NETFramework", and added所以我已经安装了包“NETStandard.Library.NETFramework”,并添加了

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

to the csproj.到 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)?有没有办法将 NetStandard 2.0 包安装到我的项目中(无需升级 VS 或安装任何 Net Core 目标包等)?

Thanks谢谢

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)?有没有办法将 NetStandard 2.0 包安装到我的项目中(无需升级 VS 或安装任何 Net Core 目标包等)?

I am afraid not.恐怕不行。 Just like Jon pointed out that the reason for that issue is that you are using Visual Studio 2015.就像 Jon 指出的那样,该问题的原因是您使用的是 Visual Studio 2015。

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

在此处输入图片说明

So we need install .NET Core 2.0 SDK.所以我们需要安装 .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.微软关于 .NET Core 2.0 预览版的每一次交流都提到了Visual Studio 2017 ,所以我认为强烈建议使用 Visual Studio 2017 来与 .NET Core 2.0 一起工作。

Besides, the NuGet package NETStandard.Library.NETFramework is deprecated .此外,NuGet 包NETStandard.Library.NETFramework弃用

在此处输入图片说明

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.因此,将 .NetStandard 2.0 Nuget 包安装到 Net 4.6.1 项目中,我强烈建议使用 Visual Studio 2017 来处理 .NET Core 2.0。

Hope this helps.希望这会有所帮助。

Referencing .NET Standard 2.0 packages is supported using the following:使用以下支持引用 .NET Standard 2.0 包:

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.使用 .NET Standard 2.0 库时仍然存在一些错误,尤其是在混合使用 .NET Standard < 2.0 和 2.0 库时,但这些更新提供了基本支持。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM