. NET Overview (2). NET Core 2.0 features introduction and Usage guide

Source: Internet
Author: User
Tags dotnet hex to binary docker hub

. NET Core 2.0 Release Date: August 14, 2017 foreword

This one will be long, introducing the. NET Core 2.0 new features, tool support and system ecology, status and future plans, can be read as a technology overview, can also be used as a learning path, outline.

For the release of. NET Core 2.0, around the 2.0 architecture, I want to go through a series to fully introduce:. NET Overview (1). NET Standard 2.0 features introduction and Usage Guidelines (published). NET Overview (2). NET Core 2.0 features introduction and Usage Guidelines (published). NET Overview (3) ASP.net Core 2.0 features introduction and use Guide. NET Overview (4) Entity Framework Core 2.0 features Introduction and Usage guide

. NET Core 2.0 release final release, projects based on the. NET Core 2.0 can be assured for production environments.. NET Core 2.0 development is not affected by development tools, and you can use command-line tools after you install the SDK, Visual Studio Code or your favorite text editor to write the project, of course, for the heavyweight IDE needs to update to the latest version: Visual Studio 2017 15.3, Visual Studio for MAC 7.1.

Note: VS 2017 15.3 does not contain an SDK and requires separate installation of the. NET Core 2.0 SDK.

Individuals prefer to use the lightweight editor Visual Studio Code, and updating Visual Studio 2017 15.3 is a very small project for me, but this latest version provides unit tests for the live units testing feature that other Ides cannot compare. This will be a favorite of TDD developers.

The. NET core 2.0 has made a number of important improvements that make the. NET core 2.0 more capable of being a platform. This article summarizes the latest features of the. NET Core 2.0, details improvements, and can refer to the GitHub Issues:dotnet/core #812. Features Overview The main performance of Runtime (runtime) Runtime and framework implementation. NET Standard 2.0 More distributions, new 6 platform support, including Debian Stretch, SUSE Linux Enterprise Server 12 SP2, and MacOS high Sierra. Ryujit is the x86 JIT in. NET Core 2.0 Linux and Windows ARM32 builds have been released preview SDK dotnet Restore is now an implicit command (automatically performed when needed). NET core and. NET Standard projects can refer to the. NET Framework nuget packages, projects, and Assemblies. The. NET core SDK can be compiled with source code, compiled codes and scripts see Source-build repo Visual S Tudio support for improvement of the. NET Core Project Live unit Testing Code navigation C # Azure function support CI/CD support container use guide to quickly use. NET Core 2.0

First, install the. NET Core SDK 2.0. (runtime already included in the SDK)

After the installation is complete, you can use the command line or Visual Studio to create a. NET Core 2.0 application.

Creating a new project is an extremely simple operation, you can use the provided project template in Visual Studio 2017, or you can use the command dotnet new to execute command creation:

C:\samples>dotnet new Console-o Console-app
c:\samples>cd console-app
c:\samples\console-app> dotnet Run
Hello world!
Project and class library upgrades

You can upgrade your existing programs to. NET Core 2.0. In Visual Studio, change the target framework to. NET Core 2.0.

If you use Visual Studio code or another code editor, manually edit the project file to change the target frame to netcoreapp2.0

<PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
</propertygroup >
relationship between. NET Core 2.0 and 1.0/1.1

The three versions are self-contained and can coexist, and the corresponding runtime is used separately, and the project is not automatically upgraded unless the corresponding version is set.

In the development environment, with more than one SDK version installed, the latest version is used by default, and after the. NET Core 2.0 SDK is installed, for all newly created projects, projects designated as versions 1.0 and 1.1 are still running with the corresponding version.

Adding a Global.json profile to a project allows you to specify the use of a specific SDK version. . NET CORE rumtime Improvements

There are the following major improvements to performance

With a number of performance improvements in. NET Core 2.0, the development team released a series of articles describing the details of the. NET core runtime improvements: performance improvements in. NET Core performance Improvemen TS in Ryujit the. NET Framework profile-guided optimization in. NET Core 2.0. NET Core 2.0 is based on. NET Standard 2.0

. NET Core 2.0 implements the. NET Standard 2.0 specification.

See diff between. NET core 2.0 and. NET Standard 2.0 for the. NET Core 2.0 provider API and. NET Standard 2.0 specification. It's easier to implement Linux as a single operating system

. NET Core 2.0 treats Linux as a single operating system. (Linux has a lot of versions, this support means that in our eyes the different versions are Linux, ignoring the differences, improve the Linux system compatibility.) There is now a separate Linux build (built on a chip architecture) that works for all the Linux distributions tested. To date, support is limited to glibc distributions, especially Linux distributions based on Debian and red Hat.

The plan will also support more other Linux distributions.

There are similar improvements in Windows and MacOS. You can now publish the project to the following runtime: linux-x64, Linux-arm win-x64, win-x86 osx-x64 Linux and Windows ARM32 build now available (preview)

The. NET core development team is building support for the. NET core 2.0+ development ARM32.

These constructs are ideal for use in raspberry pie. These builds have not yet been officially released and are now just previews. Provides the. NET Core 2.0 Build ARM32 Runtime (no SDK). Therefore, you need to build the application on another operating system and then copy it to the Raspberry Pi (or similar device).

Here are two great examples of. NET Core ARM32 development:. NET core on Raspberry Pi. NET core Docker Samples globalization mode

The. NET Core 2.0 contains the new opt-in globalization mode, providing basic globalization-related functionality consistent with operating systems and languages. The advantage of this new model is that it is consistent and without any globalization dependency.

See. NET Core Globalization Invariant mode For more information about this feature. . NET Core SDK Improvements

Here is the main improvement dotnet restore adjustment to implicit command

Invoked automatically when needed, dotnet restore is a frequently used command that restores dependent reference packages when used for project reference updates, but it is very easy to forget, although there are no updates that are prompted to do so.

Now, when we execute the command, such as: Run,build,publish, the dotnet restore is invoked automatically.

The following example shows

 c:\users\rich>dotnet New Mvc-o mvcapp the template "asp.net Core Web App (Model-view-controller)" was created suc
Cessfully.

This template contains technologies to parties other than Microsoft, and for details.
Processing post-creation actions ...
Running ' dotnet restore ' on mvcapp\mvcapp.csproj ...
Restoring packages for C:\Users\rich\mvcapp\mvcapp.csproj ...
Restore completed in 32.3 ms for C:\Users\rich\mvcapp\mvcapp.csproj.
Generating MSBuild file C:\Users\rich\mvcapp\obj\mvcapp.csproj.nuget.g.props.
Generating MSBuild file C:\Users\rich\mvcapp\obj\mvcapp.csproj.nuget.g.targets.
Restore completed in 2.26 sec for C:\Users\rich\mvcapp\mvcapp.csproj.

Restore succeeded. C:\USERS\RICH>CD Mvcapp c:\users\rich\mvcapp>dotnet Run Hosting environment:production Content root Path:c:\user S\rich\mvcapp now listening on:http://localhost:5000 application started.
Press CTRL + C to shut down. Application is shutting down ... 

When you create a project, the dotnet Restore command is automatically invoked. referencing the. NET Framework class library in a. NET Standard project

This feature will help us quickly migrate the. NET Framework to. NET Standard or. NET Core, which is used directly in the process of migration, and migrates throughout the project over time (starting with binaries and then moving to source code).

This feature also provides a new running framework support for the. NET Framework class Library.

After the. NET Framework class library is referenced, the types in the class library are limited to types that are supported in the. NET Standard API collection, so be cautious and complete the test.

The class library supports the. NET Framework 4.6.1, or earlier versions, even the 1.0 version. The following illustration shows the use of this feature:

The target framework for an assembly can be seen from the application's call stack.

. NET Standard NuGet Packages need no dependencies

The framework target for the class library is set to. NET Standard 2.0 or higher, and the underlying dependencies are provided directly by the. NET Core SDK without any dependencies.

The following is the NuGet package profile for the. NET Standard 2.0 for the target framework:

<?xml version= "1.0" encoding= "Utf-8"?> <package xmlns=
"http://schemas.microsoft.com/packaging/2012/" 06/nuspec.xsd ">
    <metadata>
        <id>ClassLibrary1</id>
        <version>1.0.0</ version>
        <authors>ClassLibrary1</authors>
        <owners>ClassLibrary1</owners>
        <requireLicenseAcceptance>false</requireLicenseAcceptance>
        <description>package description</description>
        <dependencies>
            <group targetframework= ". NETStandard2.0 "/>
        </dependencies>
    </metadata>
</package>

The following is the NuGet package profile for the. NET Standard 1.4 for the target framework:

<?xml version= "1.0" encoding= "Utf-8"?> <package xmlns=
"http://schemas.microsoft.com/packaging/2012/" 06/nuspec.xsd ">
    <metadata>
        <id>ClassLibrary1</id>
        <version>1.0.0</ version>
        <authors>ClassLibrary1</authors>
        <owners>ClassLibrary1</owners>
        <requireLicenseAcceptance>false</requireLicenseAcceptance>
        <description>package description</description>
        <dependencies>
            <group targetframework= ". NETStandard1.4 ">
                <dependency id=" netstandard.library version= "1.6.1" exclude= "Build,analyzers"/>
            </group>
        </dependencies>
    </metadata>
</package>
Visual Studio 2017 15.3 Update SDK Concurrent Support

The latest version of VS, you can identify the latest. NET Core SDK and apply the relevant tools. In version 15.3, Visual Studio provides parallel support for the. NET Core SDK by using the highest. NET Core SDK version installed by default when creating new projects, while allowing you to specify and use older versions when needed by using Global.json.

This allows you to use VS to build applications for different. NET core versions. Visual Basic Support

In addition to supporting C # and f#,15.3, you now support the use of Visual Basic to develop. NET core applications. Live Unit Testing Support

Live Unit Testing (LUT) is a new feature in Visual Studio 2017 Enterprise Edition that supports. NET core applications in 15.3. Users who love test-driven development (TDD) will certainly love this new feature.

The Enable step is simple: test->live unit Testing->start

As shown in the following illustration, when we enable LUT, you can view the unit test overlay and test results feedback in real time in the Code editor, noting the test case on the left and the tested code on the right. (This is good.) )

IDE Productivity Enhancements

Visual Studio 2017 15.3 offers a number of productivity enhancements that help you write better code faster. It is now supported to set the. NET naming conventions and formatting rules through Editorconfig, which allows your team to execute and configure coding conventions for almost all code. (The team develops a unified code specification for pain points that are resolved.) Praise. )

Code navigation Improvements: Add Gotoall (ctrl+t) Support CamelCase matching (uppercase short match), only need to enter abbreviations, you can navigate to any file, type, member definition, such as: BH will search BusHelper.cs.

You can also see the proposed variable name in the following illustration, which follows the code specification in the editor configuration:

New Partial Refactoring: Resolve merge conflicts (Resolve merge conflict) add parameters (inferred from call method) generate overload (Overrides) Add named argument Add null-check for parameters I Nsert digit-separators into literals change base for numeric * literals (e.g., hex to binary) Convert If-to-switch Remove Unused variable project system optimization

Optimizes the project file. csproj to remove parts of unwanted elements. From the following figure you can see that the dependencies of the project are sorted and structured more clearly.

Another enhancement to the. NET core project system is that project compilation is more efficient. Docker Support

The. NET Core 2.0 project can better support Docker:docker latest tag moved to. NET Core 2.0 Microsoft/dotnet Docker Hub README adopted Segmente D os/arch Style Linux ARM32 Docker images are now available. . NET Core 2.0 Multi-arch tags now use the Debian Stretch. NET core Docker images use Multi-arch based tags. NET core supports Multi-Stage Build version support and lifecycle

. NET Core 2.0 can be applied to a production environment.

Microsoft has two levels of support: long-term support (long Term support-lts) and current releases. The LTS version has three years of support, while the current version is shorter, usually around a year or even shorter. The current version is also known as fast Track support.. NET Core 1.0 and 1.1 is a LTS version.

. NET Core 2.0 is supported by the current version and is waiting for feedback on quality and reliability, and then will go to LTS support. In general, when you publish a LTS version, make sure that it is in a phase where you only need to provide security fixes, and once you have deployed a LTS version of your application, you should not update it, at least not because of the platform.

Red hat fully supports. NET Core and will soon release the appropriate version, which can be viewed redhatloves.net the site.

Do you remember these pictures. Microsoft's high profile love Linux

Of course, love is mutual, Microsoft spent three years finally also harvested the feeling of being loved, the final direction of technology is: Fusion , moving O (∩_∩) o~.

last

2.0 is an important milestone version of the. NET core, which is very exciting. 2.0 is not only present at all. NET Framework, and. NET Standard 2.0 has also achieved the promise: let. NET is everywhere. Combined with the Visual Studio family,. NET Core provides developers with the most efficient and open platforms for Windows, MacOS, and Linux systems. write to yourself.

Writing an article is really a mental and physical things, the finishing and editing of this article lasted two days to complete, the calculation will take about 4 hours, feeling write code much better, may have not yet adapted to write things, but I will insist on updating this series. Hopefully more people will learn about. NET Core at the first time.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.