繁体   English   中英

面向.net 4.7.1的项目无法引用依赖于.net standard 2.0的NuGet程序包

[英]Project that targets .net 4.7.1 cannot reference a NuGet package that depends on .net standard 2.0

我有一个针对.net 4.7.1的ASP .Net项目。 我正在尝试添加Microsoft.AspNetCore.DataProtection程序包 (取决于.net标准2.0)。

我以为.net 4.7.1是.net标准2.0的一部分 ,但是当我尝试添加此软件包时,NuGet会告诉我以下内容。

Attempting to gather dependency information for package 'Microsoft.AspNetCore.DataProtection.2.0.2' with respect to project 'IssueCenter.Website', targeting '.NETFramework,Version=v4.7.1'
Gathering dependency information took 239,47 ms
Attempting to resolve dependencies for package 'Microsoft.AspNetCore.DataProtection.2.0.2' with DependencyBehavior 'Lowest'
Resolving dependency information took 0 ms
Resolving actions to install package 'Microsoft.AspNetCore.DataProtection.2.0.2'
Resolved actions to install package 'Microsoft.AspNetCore.DataProtection.2.0.2'
Retrieving package 'Microsoft.AspNetCore.DataProtection 2.0.2' from 'NuGet official package source'.
  GET https://www.nuget.org/api/v2/package/Microsoft.AspNetCore.DataProtection/2.0.2
  OK https://www.nuget.org/api/v2/package/Microsoft.AspNetCore.DataProtection/2.0.2 291ms
Installing Microsoft.AspNetCore.DataProtection 2.0.2.
Install failed. Rolling back...
Package 'Microsoft.AspNetCore.DataProtection.2.0.2' does not exist in project 'IssueCenter.Website'
Package 'Microsoft.AspNetCore.DataProtection.2.0.2' does not exist in folder 'D:\projetos\IssueCenter\DotNet\IssueCenter2.DotNet\packages'
Executing nuget actions took 984,59 ms
Could not install package 'Microsoft.AspNetCore.DataProtection 2.0.2'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.7.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.
Time Elapsed: 00:00:01.4162507
========== Finished ==========

它发生在Visual Studio 2012和Visual Studio 2017上。

Microsoft Visual Studio Community 2017  15.0.26228.4 D15RTWSVC

Microsoft .NET Framework                4.7.02556

NuGet Package Manager                   4.0.0

如何将Microsoft.AspNetCore.DataProtection包添加到.net 4.7.1项目中?

在VS 15.3中添加了NetStandard 2.0支持,您的15.0 RTW版本将无法安装.NET Standard 2.0软件包。

使用.NET Standard程序集时,您可能会在(经典)ASP.NET应用程序中遇到问题。 查看关于此主题dotnet / Announcements GitHub问题 ,尤其是:

Web应用程序和网站不支持自动绑定重定向生成。 为了解决绑定冲突,您需要双击错误列表中的警告,Visual Studio会将它们添加到您的web.config文件中。

暂无
暂无

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

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