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

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

问题描述

我正在做一个网络库(

一些快速说明:

<块引用>
  • 如果库面向 .NET Platform Standard 1.3 版,则它只能在 .NET Framework 4.6 或更高版本、.NET Core、通用 Windows 上运行平台 10 (UWP) 和 Mono/Xamarin 平台.
  • 如果一个库针对.NET Platform Standard 1.3 版,它可以使用所有库以前的 .NET 平台标准版本(1.2、1.1、1.0).
  • 该最早支持 .NET Platform Standard 版本的 .NET Framework是 .NET Framework 4.5.这是因为新的可移植 API 表面区域(又名基于 System.Runtime 的表面积)用作.NET 平台标准的基础仅在该版本的 .NET Framework.面向 .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天全站免登陆