简体   繁体   English

.NET Core和.NET Framework的C#库

[英]C# library for .NET Core and .NET Framework

I'm doing a Network library ( https://github.com/Eastrall/Ether.Network ) for now targeting the .NET Core framework, but I want support both .NET Core and .NET Framework (4.*) 我正在做一个网络库( https://github.com/Eastrall/Ether.Network ),现在针对.NET Core框架,但我想同时支持.NET Core和.NET Framework(4. *)

I heard about adding some lines on the project.json is this a good solution? 我听说过要在project.json上添加一些行,这是一个好的解决方案吗?

Can someone help me with this? 有人可以帮我弄这个吗? Thanks 谢谢

Yes, modifying project.json is what you need. 是的,您需要修改project.json It should look like: 它应该看起来像:

{
  "version": "1.0.0",

  "dependencies": {
    "NETStandard.Library": "1.6.0"
  },

  "frameworks": {
    "netstandard1.3": {
      "imports": "dnxcore50"
    }
  }
}

Here is a scheme of mapping the .NET Platform Standard to platforms of interest from the official documentation : 这是一种将.NET平台标准映射到官方文档中感兴趣的平台的方案:

在此处输入图片说明

A few quick notes: 快速注意事项:

  • If a library targets .NET Platform Standard version 1.3, it can only run on .NET Framework 4.6 or later, .NET Core, Universal Windows Platform 10 (UWP), and Mono/Xamarin platforms. 如果库针对.NET Platform Standard版本1.3,则它只能在.NET Framework 4.6或更高版本,.NET Core,通用Windows Platform 10(UWP)和Mono / Xamarin平台上运行。
  • If a library targets .NET Platform Standard version 1.3, it can consume libraries from all previous .NET Platform Standard versions (1.2, 1.1, 1.0). 如果库针对.NET Platform Standard版本1.3,则可以使用所有以前的.NET Platform Standard版本(1.2、1.1、1.0)的库。
  • The earliest .NET Framework to support a .NET Platform Standard version is .NET Framework 4.5. 支持.NET Platform Standard版本的最早的.NET Framework是.NET Framework 4.5。 This is because the new portable API surface area (aka System.Runtime based surface area) that is used as the foundation for the .NET Platform Standard only became available in that version of .NET Framework. 这是因为用作.NET平台标准基础的新的可移植API表面积(也称为基于System.Runtime的表面积)仅在该版本的.NET Framework中可用。 Targeting .NET Framework <= 4.0 requires multi-targeting. 定位.NET Framework <= 4.0需要多目标。

For further details it is recommended to check out the official documentation . 有关更多详细信息,建议查阅官方文档

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

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