码迷,mamicode.com
首页 > Web开发 > 详细

Introducing .NET Core(.NET Core介绍)

时间:2016-01-10 19:56:18      阅读:420      评论:0      收藏:0      [点我收藏+]

标签:

    本菜鸟基本是个英盲,此篇外博是我用有道翻译的,好在内容还算简单,但愿不会误人子弟。英语好的同志们可直接去看原文: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)

Introducing .NET Core(.NET Core介绍)

标签:

原文地址:http://www.cnblogs.com/sad-bird/p/net-core.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!