将 .NetStandard 2.0 Nuget 包安装到 VS2015 Net 4.6.1 项目中
Installing a .NetStandard 2.0 Nuget package into a VS2015 Net 4.6.1 project
我正在尝试将针对 .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
我已按照此处列出的步骤操作:
所以我安装了软件包 "NETStandard.Library.NETFramework",并添加了
<PropertyGroup>
<PackageTargetFallback>netstandard2.0</PackageTargetFallback>
</PropertyGroup>
到 csproj。但是,没有运气 - 仍然是同样的问题。
有什么方法可以将 NetStandard 2.0 包安装到我的项目中(无需升级 VS 或安装任何 Net Core 目标包等)?
谢谢
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)?
恐怕不会。就像乔恩指出的那样,这个问题的原因是您使用的是 Visual Studio 2015.
根据 .NET Standard,.NET Standard 2.0 支持 .NET Framework 4.6.1(使用 .NET Core 2.0 SDK):
所以我们需要安装.NET Core 2.0 SDK。微软关于 .NET Core 2.0 预览版的每一次沟通都提到 Visual Studio 2017,所以我认为强烈建议使用 Visual Studio 2017 来与 .NET 一起工作核心 2.0.
此外,NuGet 包 NETStandard.Library.NETFramework 已 弃用 。
因此,将 .NetStandard 2.0 Nuget 包安装到 Net 4.6.1 项目中,我强烈建议使用 Visual Studio 2017 来与 .NET Core 2.0 一起工作。
希望对您有所帮助。
使用以下支持引用 .NET Standard 2.0 包:
- VS 2015 的 NuGet 3.6.0 或更高版本(来自 NuGet's download site - 可能尚未列为推荐的最新版本)
- 从 https://aka.ms/netstandard-build-support-netfx 安装“Visual Studio 2015 的 .NET 标准支持”(VS 中的 NuGet 也会在其输出 window 中为此打印 link) .
在使用 .NET Standard 2.0 库时仍然存在一些错误,尤其是在混合使用 .NET Standard < 2.0 和 2.0 库时,但这些更新提供了基本支持。
我正在尝试将针对 .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
我已按照此处列出的步骤操作:
所以我安装了软件包 "NETStandard.Library.NETFramework",并添加了
<PropertyGroup>
<PackageTargetFallback>netstandard2.0</PackageTargetFallback>
</PropertyGroup>
到 csproj。但是,没有运气 - 仍然是同样的问题。
有什么方法可以将 NetStandard 2.0 包安装到我的项目中(无需升级 VS 或安装任何 Net Core 目标包等)?
谢谢
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)?
恐怕不会。就像乔恩指出的那样,这个问题的原因是您使用的是 Visual Studio 2015.
根据 .NET Standard,.NET Standard 2.0 支持 .NET Framework 4.6.1(使用 .NET Core 2.0 SDK):
所以我们需要安装.NET Core 2.0 SDK。微软关于 .NET Core 2.0 预览版的每一次沟通都提到 Visual Studio 2017,所以我认为强烈建议使用 Visual Studio 2017 来与 .NET 一起工作核心 2.0.
此外,NuGet 包 NETStandard.Library.NETFramework 已 弃用 。
因此,将 .NetStandard 2.0 Nuget 包安装到 Net 4.6.1 项目中,我强烈建议使用 Visual Studio 2017 来与 .NET Core 2.0 一起工作。
希望对您有所帮助。
使用以下支持引用 .NET Standard 2.0 包:
- VS 2015 的 NuGet 3.6.0 或更高版本(来自 NuGet's download site - 可能尚未列为推荐的最新版本)
- 从 https://aka.ms/netstandard-build-support-netfx 安装“Visual Studio 2015 的 .NET 标准支持”(VS 中的 NuGet 也会在其输出 window 中为此打印 link) .
在使用 .NET Standard 2.0 库时仍然存在一些错误,尤其是在混合使用 .NET Standard < 2.0 和 2.0 库时,但这些更新提供了基本支持。