Home .Net New Features in .NET Core 2.0

New Features in .NET Core 2.0

by Dhanik Lal Sahni

.NET Core is a cross-platform, open source, and modular .NET platform for creating modern web apps, microservices, libraries and console applications. This release includes the .NET Core runtime, libraries and tools and the ASP.NET Core libraries

Microsoft has launched .NET Core 2.0 on 14-Aug-2017 with some new enhancements in some of the feature categories which are listed below. We will understand each feature changes here.

  • Tooling
  • Language support
  • Platform improvements
  • API changes
  • Visual Studio integration

We need to install .NET Core SDK 2.0 for getting .NET Core 2.0.

Tooling

1. dotnet restore runs automatically with commands

In .NET Core 1.x application, we need to run dotnet restore command whenever we add new dependency or create project using command line tool dotnet new.

In .NET 2.0 this has been improved and now we don’t require dotnet restore command. It will implicitly runs when dotnet newcommand executed.

dotnet restore will also implicitly run when dependencies will be updated. This will also executed when run build and publishcommand executed.

If we dont want dotnet restore to be excuted implicitly then we can ignore that using --no-restore with new run build packpublishand test commands.

2. Upgrading to .NET Core 2.0

If we have application which is built in .NET Core 1.x and .NET Core 2.0 is installed then we can upgrade application to .NET Core 2.0by just changing into proj file. We need to change <TargetFrameworks> element like below.

    <PropertyGroup>
        <TargetFramework>netcoreapp2.0</TargetFramework>
    </PropertyGroup>

We also have to update package references in proj file to use latest references

    <ItemGroup>
        <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
    </ItemGroup>

If we have global.json for .NET Core SDK version then we can upgrade that too with below change in global.json file

 {
  "sdk": {
    "version": "2.0.0"
  }
}

Language support

1. Visual Basic

.NET core framework is now supporting Visual Basic language also. We can create below projects in visual basic language

  • .NET Core console apps
  • .NET Core class libraries
  • .NET Standard class libraries
  • .NET Core unit test projects
  • .NET Core xUnit test projects

2. Support for C# 7.1

.NET Core 2.0 support C#7.1 features. C#7.1 has many new features which give strong development enviornment. Some of the featues are marked below.

  • Async Main Method
  • Tuple types and Tuple literals
  • Pattern Matching
  • Return by Ref
  • Default Expression
  • Throw Exception from Expression

Platform improvements

.NET Core 2.0 includes many features that make it easier to install .NET Core and to use it on supported operating systems.

1. .NET Core for Linux is a single implementation

In .NET Core 1.x, we had to distribute specific Linux build. In .NET Core 2.0, Linux is now a single Operating System. We have to build and distribute single build and it will work on all Linux distros

API changes

Support for .NET Standard 2.0

.NET Core 1.x supports the .NET Standard version 1.6; .NET Core 2.0 supports the latest version, .NET Standard 2.0. .NET Standard 2.0 includes over 20,000 more APIs than were available in the .NET Standard 1.6

Visual Studio integration

Visual Studio 2017 version 15.3 and in some cases Visual Studio for Mac offer a number of significant enhancements for .NET Core developers.

1. Better support for multiple target frameworks

If we are building a project for multiple target frameworks, we can now select the target platform from the top-level menu. In the following figure, a project named SCD1 targets 64-bit Mac OS X 10.11 (osx.10.11-x64) and 64-bit Windows 10/Windows Server 2016 (win10-x64).

2. Live Unit Testing support for .NET Core

Whenever we modify our code, Live Unit Testing automatically runs any affected unit tests in the background and displays the results and code coverage live in the Visual Studio environment.

Summary

.NET Core 2.0 is loaded with so many features and it will make framework very competitive with other frameworks.

You Might Be Interested In

You may also like

Leave a Comment

Adblock Detected

Please support us by disabling your AdBlocker extension from your browsers for our website.