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

查看:252
本文介绍了.NET Core和.NET Framework的C#库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做一个网络库(



一些简短说明:



  • 如果有图书馆针对.NET Platform Standard版本1.3,它只能在.NET Framework 4.6或更高版本,.NET Core,通用Windows
    Platform 10(UWP)和Mon上运行
    。 o / Xamarin平台。

  • 如果某个库以
    .NET Platform Standard版本1.3为目标,则它可以使用所有
    以前的.NET Platform Standard版本(1.2、1.1、1.0)中的库。

  • 支持.NET平台标准版本
    的最早的.NET Framework是.NET Framework 4.5。这是因为用作.NET Platform Standard的
    基础的新的可移植API表面
    区域(也称为System.Runtime基于表面积)仅在该版本的
    中可用。 NET框架。定位.NET Framework< = 4.0
    需要多目标。


详细信息,建议查看官方文档


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.*)

I heard about adding some lines on the project.json is this a good solution?

Can someone help me with this? Thanks

解决方案

Yes, modifying project.json is what you need. 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:

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.
  • 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).
  • The earliest .NET Framework to support a .NET Platform Standard version is .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. Targeting .NET Framework <= 4.0 requires multi-targeting.

For further details it is recommended to check out the official documentation.

这篇关于.NET Core和.NET Framework的C#库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆