为跨平台开源 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?

查看:31
本文介绍了为跨平台开源 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 Framework)
  4. 类库(便携式)

我听说 Portable 就是它所说的,但现在我们有了可以在 Linux 和 Mac 上运行的 Core(也许还有 Windows Phone 和 Xamarin?),而且我几乎没有遇到任何问题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天全站免登陆