为跨平台开源 UI 不可知 C# 类库选择哪种 Visual Studio 2017 项目类型,为什么? [英] Which Visual Studio 2017 project type to choose for a cross-platform open-source UI-agnostic C# class library and why?

查看:18
本文介绍了为跨平台开源 UI 不可知 C# 类库选择哪种 Visual Studio 2017 项目类型,为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想开发一个 C# 类库并将其发布为开源.我想让它在尽可能多的可用 .Net 平台上(例如完整的 .Net、Mono、.Net Core、Xamarin,只有经典的 .Net 兼容性是真正必须的,然而).该库不会依赖任何与 UI 相关的东西,也不依赖于 WPF 之类的仅限 Windows 的东西.

I've got an idea of a C# class library I would like to develop and release to open-source. I would like to make it easily available (with recompilation if necessary) on as many of the available .Net platforms as possible (e.g. full .Net, Mono, .Net Core, Xamarin, only the classic .Net compatibility is a real must, however). The library is not going to depend on anything UI-related nor Windows-only stuff like WPF.

我需要的是:

  1. 常见的 .Net 类型和 API(我不想因为缺少我认为是语言必不可少的部分而感到惊讶)
  2. JSON 和 XML 操作工具
  3. 文件系统访问(可能有些限制),
  4. HTTPS 客户端,
  5. SQL 级别的 RDBMS 客户端(我不需要 ORM 功能,但当然不介意它可用)
  6. 如果可能,请反思
  7. 如果可能,异步和线程设施
  8. 可能是最新版本的 C# 语言

我正在选择以下项目类型

I am choosing between the following project types

  1. 类库(.NET Core)
  2. 类库(.NET 标准)
  3. 类库(.NET 框架)
  4. 类库(便携式)

我听说 Portable 就是它所说的,但现在我们已经有了可以在 Linux 和 Mac 上运行的 Core(也许是 Windows Phone 和 Xamarin?)而且我几乎没有问题,使用 EF Core 显然在我的经典中针对它Windows 桌面 .NET Framework 应用程序.由于 Mono 和 Xamarin,经典 .NET Framework 代码似乎在非 Windows 平台上得到了很好的支持..NET Standard - 我不知道这是什么意思,我刚刚通过新项目"窗口搜索工具通过查找所有种类的类库"发现了这种类型.

I have heard that Portable is what it says but now we've got Core that runs on Linux and Mac (Windows Phone and Xamarin too perhaps?) and I have almost no problems using EF Core that obviously targets it in my classic Windows Desktop .NET Framework apps. Classic .NET Framework code seems to be quite well supported on non-Windows platforms thanks to Mono and Xamarin. .NET Standard - I have no clue what does this mean, I've just discovered this type with the "New Project" window search tool by looking for all the varieties of "Class Library".

我应该选择哪一个,为什么,我应该知道什么?

Which one should I choose, why, and what should I know about it?

推荐答案

  • .NET 标准类库:最大的灵活性,应该能够在各种 .NET 应用程序/平台中使用(不断发展,因为 Unity 尚未涵盖).
  • .NET Framework 类库:您还应该知道的旧知识.
  • .NET Core 类库:在 .NET Core 应用程序之间共享代码.它存在,因为 .NET Standard 类库有其局限性(配置文件表面通常小于 .NET Core 应用).
  • 可移植类库 (PCL):您现在可以避免使用它们,除非您确实需要支持旧平台.使用 .NET Standard 效果更好,而且面向未来.
  • 您可以轻松地运行一些实验来断言我上面所做的陈述.

    You can easily run a few experiments to assert the statements I made above.

    作为一个库发布者,我现在选择发布包含 .NET Framework 版本、.NET Standard 版本和 PCL 版本的 NuGet 包,从长远来看会逐渐放弃 .NET Framework 和 PCL 版本.许多其他图书馆也这样做.

    As a library publisher myself, I choose to ship NuGet packages containing .NET Framework version, .NET Standard version, and PCL version at this moment, and would gradually drop .NET Framework and PCL versions in the long run. Many other libraries do the same.

    我还写了一篇博文来介绍更多内容,

    I also wrote a blog post to cover more,

    https://blog.lextudio.com/which-class-library-project-to-go-in-visual-studio-2015-2017-a48710cf3dff

    这篇关于为跨平台开源 UI 不可知 C# 类库选择哪种 Visual Studio 2017 项目类型,为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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