Introducing .NET Core(.NET Core介绍)

本菜鸟基本是个英盲,此篇外博是我用有道翻译的,好在内容还算简单,但愿不会误人子弟。英语好的同志们可直接去看原文:https://docs.asp.net/en/latest/getting-started/installing-on-windows.html,如果有人能重新翻译发布出来让大家学习那再好不过,省得我这种人一个一个地查单词。

欢迎指正!

By Steve Smith

作者Steve Smith

.NET Core is a small, optimized runtime that can be targeted by ASP.NET 5 applications. In fact, the new ASP.NET 5 project templates target .NET Core by default, in addition to the .NET Framework. Learn what targeting .NET Core means for your ASP.NET 5 application.

.NET Core是一个小的,优化了的.NET 5运行时。事实上,新的ASP.NET 5项目模板默认目标是.NET Core,除.NET Framework之外。ASP.NET 5应用以.NET Core为目标(此处不会翻译了)。

    In this article(此篇文章包括以下小节):

What is .NET Core(什么是.NET Core)

.NET Core 5 is a modular runtime and library implementation that includes a subset of the .NET Framework. Currently it is feature complete on Windows, and in-progress builds exist for both Linux and OS X. .NET Core consists of a set of libraries, called “CoreFX”, and a small, optimized runtime, called “CoreCLR”. .NET Core is open-source, so you can follow progress on the project and contribute to it on GitHub:

.NET Core 5是一个更模块化的运行时和库实现,是.NET Framework的子集。当前在Windows上功能齐全,为Linux和OS X构造的还未完成。.NET Core由一系列叫做“CoreFX”的库和精简的,优化的叫做“CoreCLR”运行时组成。.NET Core 是开源的,所以你可以在GitHub上跟进项目并为它贡献代码。

The CoreCLR runtime (Microsoft.CoreCLR) and CoreFX libraries are distributed via NuGet. The CoreFX libraries are factored as individual NuGet packages according to functionality, named “System.[module]” on nuget.org.

CoreCLR和CoreFX都经由NuGet发布。CoreFX被按功能分解为几个单独的被命名为“System.[模块名]”的NuGet包。

One of the key benefits of .NET Core is its portability. You can package and deploy the CoreCLR with your application, eliminating your application’s dependency on an installed version of .NET (e.g. .NET Framework on Windows). You can host multiple applications side-by-side using different versions of the CoreCLR, and upgrade them individually, rather than being forced to upgrade all of them simultaneously.

.NET Core的一个主要好处是它的可移植性。你可以将CoreCLR你的应用一起打包并部署,消除你的应用依赖于.NET某个安装版本。你可以宿主多个应用,每个应用使用不同版本的CoreCLR,并互不影响地升级它们,而不是强制同时升级它们。

CoreFX has been built as a componentized set of libraries, each requiring the minimum set of library dependencies (e.g. System.Collections only depends on System.Runtime, not System.Xml). This approach enables minimal distributions of CoreFX libraries (just the ones you need) within an application, alongside CoreCLR. CoreFX includes collections, console access, diagnostics, IO, LINQ, JSON, XML, and regular expression support, just to name a few libraries. Another benefit of CoreFX is that it allows developers to target a single common set of libraries that are supported by multiple platforms.

CoreFX被构建为一系列组件库,每个组件要求最小化的类库依赖(比如,System.Collections 仅依赖于System.Runtime,不依赖System.Xml)。这种方法使最小化CoreFX类库的分发包成为可能,以便只使用需要的。CoreFX包括集合,控制台访问,诊断,IO,LINQ,JSON,XML,和正则表达式支持,这只是其中一些例子而以。CoreFX另外一个好处是它允许开发者着眼于支持多平台的公共类库集。

Motivation Behind .NET Core(.NET Core背后的动机)

When .NET first shipped in 2002, it was a single framework, but it didn’t take long before the .NET Compact Framework shipped, providing a smaller version of .NET designed for mobile devices. Over the years, this exercise was repeated multiple times, so that today there are different flavors of .NET specific to different platforms. Add to this the further platform reach provided by Mono and Xamarin, which target Linux, Mac, and native iOS and Android devices. For each platform, a separate vertical stack consisting of runtime, framework, and app model is required to develop .NET applications. One of the primary goals of .NET Core is to provide a single, modular, cross-platform version of .NET that works the same across all of these platforms. Since .NET Core is a fully open source project, the Mono community can benefit from CoreFX libraries. .NET Core will not replace Mono, but it will allow the Mono community to reference and share, rather than duplicate, certain common libraries, and to contribute directly to CoreFX, if desired.

当.NET在2002看面世时,它是一个完整单一的框架,不久之后.NET Compact Framework面世,Compact Framework为移动设备提供了一个小的.NET版本。多年以来,就这样周而复始,所以现在有多个针对不同平台的.NET。加上由Mono和Xamarin提供的运行在Linux,Mac,和原生iOS和安卓设备上。每个平台上,都有一套自己的运行时,框架和应用模型用以开发.NET应用。.NET Core的一个主要目标是为所有的平台只提供一个单一,模块化的,跨平台的.NET版本。由于.NET Core是一个完全开源的项目,Mono社区将得益于CoreFX类库。.NET Core不会代替Mono,但它将允许Mono社区来参考和分享,而不是重写公共类库,如果愿意,可以直接向CoreFX贡献代码。

In addition to being able to target a variety of different device platforms, there was also pressure from the server side to reduce the overall footprint, and more importantly, surface area, of the .NET Framework. By factoring the CoreFX libraries and allowing individual applications to pull in only those parts of CoreFX they require (a so-called “pay-for-play” model), server-based applications built with ASP.NET 5 can minimize their dependencies. This, in turn, reduces the frequency with which patches and updates to the framework will impact these applications, since only changes made to the individual pieces of CoreFX leveraged by the application will impact the application. A smaller deployment size for the application is a side benefit, and one that makes more of a difference if many applications are deployed side-by-side on a given server.

除此跨平台之外,还有减小服务器资源占用,更重要的是,.NET Framework的体积、体量(不会翻译)。通过重构CoreFX类库和允许个别应用只引用需要的部分CoreFX,用ASP.NET 5构造的基于服务应用可以最小化它们的依赖项。反过来,减少打补丁和更新framework的频次将压缩这些应用,......此处不会翻译,请自行翻译......

Note(注意)

The overall size of .NET Core doesn’t intend to be smaller than the .NET Framework over time, but since it is pay-for-play, most applications that utilize only parts of CoreFX will have a smaller deployment footprint.

将来.NET Core的完全大小不会比.NET Framework更小,但是由于它是按需付费,更多的应用只利用CoreFX的一部分将会让部署占用更小的空间。

Building Applications with .NET Core(使用.NET Core构建应用)

.NET Core can be used to build a variety of applications using different application models including Web applications, console applications and native mobile applications. The .NET Execution Environment (DNX) provides a cross-platform runtime host that you can use to build .NET Core based applications that can run on Windows, Mac and Linux and is the foundation for running ASP.NET applications on .NET Core. Applications running on DNX can target the .NET Framework or .NET Core. In fact, DNX projects can be cross-compiled, targeting both of these frameworks in a single project, and this is how the project templates ship with Visual Studio 2015. For example, the frameworkssection of project.json in a new ASP.NET 5 web project will target dnx451 and dnxcore50 by default:

通过使用不同的应用模板,.NET Core可以用来构建各种应用,包括Web应用,控制台应用和原生移动应用。.NET 执行环境(DNX)提供一个跨平台的运行时宿主,你可以使用它来构造基于.NET Core的应用,它可以运行在Windows,Mac和Linux,并且DNX是在.NET Core上运行ASP.NET应用的基础。运行在DNX上的应用可以以.NET Framework或.NET Core为目标。事实上,DNX项目可在同一个项目中以两个框架为基础交叉编译,并且Visual Studio 2015中的项目模板就支持这样。举例说明,默认情况下,ASP.NET 5 Web 项目中project.json文件的frameworks节会被配置为以dnx451和dnxcor50为目标。

"frameworks": {
        "dnx451": { },
        "dnxcore50": { }
},

    dnx451 represents the .NET Framework, while dnxcore50 represents .NET Core 5 (5.0). You can use compiler directives (#if) to check for symbols that correspond to the two frameworks: DNX451 andDNXCORE50. If for instance you have code that uses resources that are not available as part of .NET Core, you can surround them in a conditional compilation directive:

dnx451表示.NET Framework,dnxcore50表示.NET Core 5(5.0)。你可以使用编译器指令(#if)来检查匹配DNX451和DNXCORE50的标志。例如你的代码使用的资源不是.NET Core的一部分,你可以在这块代码的外面使用条件编译指令:

#if DNX451
        // utilize resource only available with .NET Framework
#endif

The recommendation from the ASP.NET team is to target both frameworks with new applications. If you want to only target .NET Core, remove dnx451; or to only target .NET Framework, removednxcore50 from the frameworks listed in project.json. Note that ASP.NET 4.6 and earlier target and require the .NET Framework, as they always have.

ASP.NET团队的推荐做法是同时以两个框架为目标来新建应用。如果你想只针对.NET Core,就从project.json文件中移除dnx451;或只针对.NET Framework,就从project.json文件中移除dnxcore50。注意ASP.NET 4.6和更早的目标框架和要求的.NET Framework,仍如往常一样。

.NET Core and NuGet(.NET Core 和 NuGet)

Using NuGet allows for much more agile usage of the individual libraries that comprise .NET Core. It also means that an application can list a collection of NuGet packages (and associated version information) and this will comprise both system/framework as well as third-party dependencies required. Further, third-party dependencies can now also express their specific dependencies on framework features, making it much easier to ensure the proper packages and versions are pulled together during the development and build process.

使用NuGet考虑到理便捷地使用组成.NET Core的单独的类库。它也意味着一个应用可以列出一系列NuGet包(和关联的版本信息)并包含系统/框架像第三方依赖要求。进一步,第三方依赖可以表示出他们指定依赖于框架元素,使确保特定的包和版本被包含到开发和构造过程中变得非常容易。

If, for example, you need to use immutable collections, you can install the System.Collections.Immutable package via NuGet. The NuGet version will also align with the assembly version, and will use semantic versioning.

如果,例如,你需要使用不可变集合,你可以经由NuGet安装System.Collections.Immutable包。NuGet版本也匹配程序集版本,并且使用主义版本。(又不会翻译了)

Note(注意)

Although CoreFX will be made available as a fairly large number of individual NuGet packages, it will continue to ship periodically as a full unit that Microsoft has tested as a whole. These distributions will most likely ship at a lower cadence than individual packages, allowing time to perform necessary testing, fixes, and the distribution process.

尽管CoreFX将用作大量的单独的NuGet包,它将继续定期地作为一个完整的微软测试过的单位发布。这些很可能以比个别包低节奏地发布,空出时间来完成必要的测试,修补和发布过程。

Summary(总结)

.NET Core is a modular, streamlined subset of the .NET Framework and CLR. It is fully open-source and provides a common set of libraries that can be targeted across numerous platforms. Its factored approach allows applications to take dependencies only on those portions of the CoreFX that they use, and the smaller runtime is ideal for deployment to both small devices (though it doesn’t yet support any) as well as cloud-optimized environments that need to be able to run many small applications side-by-side. Support for targeting .NET Core is built into the ASP.NET 5 project templates that ship with Visual Studio 2015.

.NET Core 是个更模块化,流线型的.NET Framework和CLR的子集。它是完全开源和提供一个公共类库集,可以跨平台。它的分解方式允许仅依赖那些它们只使用的CoreFX部分,并且更小的运行时是为部署到小设备,云环境也是一样的,需要可以同时运行许多小的应用。Visual Studio 2015支持用ASP.NET 5项目模块构造.NET Core应用。

Additional Reading(附加阅读)

    Learn more about .NET Core:(更多.NET Core)
时间: 2024-10-28 19:28:09

Introducing .NET Core(.NET Core介绍)的相关文章

ASP.NET Core MVC 过滤器介绍

原文:ASP.NET Core MVC 过滤器介绍 过滤器的作用是在 Action 方法执行前或执行后做一些加工处理.使用过滤器可以避免Action方法的重复代码,例如,您可以使用异常过滤器合并异常处理的代码. 过滤器如何工作? 过滤器在 MVC Action 调用管道中运行,有时称为过滤器管道.MVC选择要执行的Action方法后,才会执行过滤器管道: 实现 过滤器同时支持同步和异步两种不同的接口定义.您可以根据执行的任务类型,选择同步或异步实现. 同步过滤器定义OnStageExecutin

.net core 反射的介绍与使用

原文:.net core 反射的介绍与使用   1. 概述反射 通过反射可以提供类型信息,从而使得我们开发人员在运行时能够利用这些信息构造和使用对象. 反射机制允许程序在执行过程中动态地添加各种功能.   2. Type类的介绍  是BCL(基底类别库)声明的一个抽象类,所有它不能被实例化 对于程序中用到的每一个类型,CLR(公共语言运行时)都会创建一个包含这个类型信息的Type类型的对象 程序中用到的每一个类型都会关联到独立的Type类型的对象 不管创建的类型有多少个实例,只有一个Type对象

UIKit,Core Data , Core Graphics, Core Animation,和OpenGLES框架

iOS的主要框架介绍 框架是一个目录,这个目录包含了共享库,访问共享库里代码的头文件,和其它的图片和声音的资源文件.一个共享库定义的方法或函数可以被应用程序调用. IOS提供了很多你可以在应用程序里调用的框架.要使用一个框架,需要将它添加到你的项目中,你的项目才可以使用它.许多应用程序都使用了如Foundation.UIKit.和Core Graphics这些框架.根据你为应用程序选择的模版,相关的框架就已经被自动引入了.如果默认加入的框架不能满足你的应用程序的需求,你也可以加入需要的框架. 看

IOS开发——Core Graphics & Core Animation

好久没写过blog了,首先了解下最近苹果和IOS方面的最新消息. 1.WWDC2014在上个月举行了,与2013年一样,今年WWDC没发布硬件产品和新品(如果你懂cook你就会期待今年秋季发布会,预计10中旬举行) 今年WWDC有一个最令人兴奋的新语言发布--Swift,小编也花了将近半个月来学习新语言,发现Swift与反人类语言objective-c不同的是完全抛弃了C,更像是js+lua+python+各种脚本语言的集合,这也是时间上最新最先进的开发语言,小道消息说swift今年4岁,也就是

asp.net core+ef core

asp.net core+ef core 官方的文档https://docs.asp.net/en/latest/tutorials/first-mvc-app/start-mvc.html 先来看一下实现的效果 开始之前,确定本机已经有.NET Core环境.https://www.microsoft.com/net/core#windows 1.创建解决方案的文件结构如下图(模糊处理的过文件是自己后面加的和ef生成的). 2.要使用ef core,先引用ef core相关的程序包.https

.net core EF Core 视图的应用

由之前的一篇文章<.net core Entity Framework 与 EF Core>我们都已经知道 EF Core 增加了许多特性,并且性能上也有了很大的提升. 但是EF Core是不支持存储过程及视图的映射的,那么直接通过 DbContext 是没有办法直接调用(就是不能直接 "点" 出来)到存储过程与视图的. 上一篇<.net core EF Core 调用存储过程>中已经讲到了存储过程的调用了,这篇就只讲视图了. 对视图来讲,在数据库中 EF Co

Core Data demo介绍

镔哥最近一直在研究Core Data 因为本人感觉一直对它有点小惧怕,因为没有用过,但是因为最近项目我考虑用CoreData做为项目的增删改查数据库:所以未来几篇的文章都应该是讲解我对CoreDAta的学习. 介绍一下: 1:记住Core Data是一个功能强大的层,位于SQLite数据库之上,它避免了SQL的复杂性,能让我们以更自然的方式与数据库进行交互.A: Core Data将数据库行转换为OC对象(托管对象)来实现,这样无需任何SQL知识就能操作他们. B: Core Data位于MVC

core bluetooth简单介绍

core bluetooth,蓝牙4.0限制: IOS6 以上 一.外设 peripheral 二.中心 central 三.服务,一个设备有多个服务:由蓝牙硬件厂商决定.决定哪些是用来交互(读写),哪些可获取模块信息(只读): 四.特征,一个服务有多个特征,特征是与外界交互的最小单位:由蓝牙硬件厂商决定.决定哪些是用来交互(读写),哪些可获取模块信息(只读): 五.外设主要类: (Main Objects)CBPeripheraManager----CBCentral (Data Object

Entity Framework Core 之简单介绍

Overview EFCore是一个以对象映射器(O/RM)为核心的轻量级.可扩展的实体框架数据访问技术,目前支持Microsoft SQL Server.SQLite.Postgres(Npgsql).InMeory等数据库技术 获取EntityFramework Core方法:通过Nuget package安装或使用命令安装SQLSERVER Concepts EntityState 跟EF6.X一样,这里也存在EntityState 成员名称 说明 Added 对象为新对象,且已添加到对象

core bluetooth详细介绍

遵守CBCentralManagerDelegate代理和CBPeripheralDelegate代理 在使用你的应用去扫描设备之前,先要确定你的蓝牙是否已经打开,所以我们要做一个判断: 其中f3d9是我连接到iPad mini2的LightBlue app模拟的BLE外围设备,你要换成你设备的UUID. centralManagerDidUpdateState是CBCentralManagerDelegate必须实现的方法 - (void)centralManagerDidUpdateStat