为跨平台的,与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?

查看:103
本文介绍了为跨平台的,与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(也许也可以是Windows Phone和Xamarin?)上运行的Core,而使用EF Core显然可以解决我的经典问题,这几乎没有问题. Windows桌面.NET Framework应用程序.得益于Mono和Xamarin,经典的.NET Framework代码似乎在非Windows平台上得到了很好的支持. .NET Standard-我不知道这是什么意思,我只是通过"New Project"窗口搜索工具通过查找"Class Library"的所有种类来发现这种类型的.

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天全站免登陆