asp.net-core - 不同版本的 netstandard 和 netcoreapp 如何兼容?

标签 asp.net-core .net-core .net-standard

我正在努力寻找任何可以回答我以下问题的官方博客文章或文档:

  • 如果我有一个 netstandard2.0 库,我可以依赖一个只针对 netstandard1.x 的库吗?
  • netstandard1.x 和 netstandard2.0 之间主要版本的变化是不兼容的迹象还是其他什么?
  • 如果我有一个面向 netstandard2.0 的库,它依赖于 ASP.NET Core 2.0.x 包(例如 Http.Abstractions),那么我可以从 netcoreapp2.1 应用程序中使用这个库吗?
  • 对 Http.Abstractions 的依赖将如何解决?它会降级整个 ​​netcoreapp2.1 应用程序吗?
  • 即使这在理论上可行,这是 Microsoft 支持的案例吗?
  • netstandard2.0 库是否应该/可以依赖于 ASP.NET Core 2.1.x NuGet 包?

  • 非常感谢!

    最佳答案

    .NET Standard 是契约。由 .NET Core Mono 实现。 .NET 框架等

    以 .NET Core 1.0 为例,as per the docs , 支持任何 .NET Standard 1.x 而 .NET Core 2.0, 支持 .NET Standard 2.0

    If I have a netstandard2.0 library, can I have a dependency on a library which has only targeted netstandard1.x?



    .较高版本的 .NET Standard 可以依赖较低版本。与较高版本的 net4x 或 netcoreapp 相同,可以依赖较低的版本。它们是 API 的 super 集。

    If I have a library targeting netstandard2.0 which has a dependency on an ASP.NET Core 2.0.x package (e.g. Http.Abstractions) can I use this library from a netcoreapp2.1 application then?



    .这是因为 Http.Abstractions 也针对 .NET Standard 而不是 .NET Core (netcoreapp)。这也是 ASP.NET Core 可以与完整框架一起使用的原因(经常引起混淆)。

    Should/can a netstandard2.0 library have a dependency on a ASP.NET Core 2.1.x NuGet package?



    . .NET Standard 不支持 .NET Core。因此,仅针对 .NET Standard 的库不能依赖于 .NET Core

    关于asp.net-core - 不同版本的 netstandard 和 netcoreapp 如何兼容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51836260/

    相关文章:

    c# - Json.Net 和 Web API 中枚举的验证

    c# - .NET Core 中的共享设置?

    linux - 未找到版本 `GLIBC_2.33'

    .net - netcoreapp2.0与netstandard2.0在图书馆项目中的优势

    c# - Xamarin .net 标准对 APK 大小的影响

    c# - 如何在我的 .NET Core API 中使用 Windows 环境变量?

    docker 想访问驱动器 c 你想共享它吗?

    c# - 使用 c# 和 Process.Start 打开默认浏览器窗口

    c# - dotnet : Works from Windows 10 command prompt, 但不在 VSCode 中

    .net-standard - 类库(标准 2.1 或核心 3.1): namespace name 'IWebHostEnvironment' could not be found