【问题标题】:Is the nuget package Microsoft.AspNet.WebApi.Core 5.2.7 compatible with .Net Core 2.2?nuget 包 Microsoft.AspNet.WebApi.Core 5.2.7 是否与 .Net Core 2.2 兼容?
【发布时间】:2019-07-26 16:27:57
【问题描述】:

我在 .NET Core 2.2 应用程序中收到以下警告:

Warning NU1701  Package 'Microsoft.AspNet.WebApi.Core 5.2.7' was restored using 
'.NETFramework,Version=v4.6.1' instead of the project target framework 
'.NETCoreApp,Version=v2.2'. 
This package may not be fully compatible with your project.

这个包有替代品吗?

【问题讨论】:

  • 不,你添加了错误的包。您无需将 any 包添加到 ASP.NET Core 项目即可创建 Web API 控制器。检查Tutorial: Create a web API with ASP.NET Core MVC。 .NET Core 中的控制器架构发生了变化,现在支持从同一个类 ControllerBase 派生的 Web API 和 MVC 控制器
  • Microsoft.AspNet.WebApi.Core 是如何最终进入 ASP.NET Core 项目的?
  • 我正在将 .net 4.5.1 应用程序升级到 .net core 2.2。我使用的是 BsonMediaTypeFormatter 和 BsonReader 等类型。我看到 Microsoft.AspNet.WebApi.Core 有这些,但不幸的是,不支持。
  • 这是一个不同的架构,不是支持与否的问题。 Web API 现在已融入 ASP.NET Core。不过,您真正的问题是不同的 - 如何将 BSON 支持添加到 ASP.NET Core?有许多重复项表明您需要添加WebAPIContrib.Core 包
  • 不要升级现有项目,因为你会错过 .NET Core 中的许多新的和很棒的东西(例如改进的 csproj 文件格式),以及可能有很多剩下的东西,以及遇到这些问题。而是创建一个新的 Core 项目,将所有代码复制到其中,然后根据需要添加缺少的引用。

标签: asp.net-core .net-core


【解决方案1】:

正如 cmets 中所说,ASP.NET Core project 不需要这样做。通过NuGet 删除它,你应该很高兴。

【讨论】:

    猜你喜欢
    • 2022-10-19
    • 1970-01-01
    • 1970-01-01
    • 2017-02-12
    • 1970-01-01
    • 2016-11-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多