Microsoft heeft enkele dagen geleden .Net Core 2.1 uitgegeven. Dit is een modulair platform voor het maken van webapplicaties en services die draaien op Linux, macOS en Windows. Het maakt natuurlijk gebruik van .Net en je kunt het vergelijken met Node.js of Go. Het geheel wordt onder een mix van MIT-, Apache 2- en CC BY 4.0-licenties uitgegeven. Deze uitgave is voorzien van de volgende aankondiging op het .Net Blog:
Announcing .NET Core 2.1
We’re excited to announce the release of .NET Core 2.1. It includes improvements to performance, to the runtime and tools. It also includes a new way to deploy tools as NuGet packages. We’ve added a new primitive type called Span that operates on data without allocations. There are many other new APIs, focused on cryptography, compression, and Windows compatibility. It is the first release to support Alpine Linux and ARM32 chips. You can start updating existing projects to target .NET Core 2.1 today. The release is compatible with .NET Core 2.0, making updating easy.
ASP.NET Core 2.1 and Entity Framework Core 2.1 are also releasing today.
.NET Core 2.1 is supported by Visual Studio 15.7, Visual Studio for Mac and Visual Studio Code.
Docker images are available at microsoft/dotnet for .NET Core and ASP.NET Core.
The Build 2018 conference was earlier this month. We had several in-depth presentations on .NET Core. Check out Build 2018 sessions for .NET on Channel9.
You can see complete details of the release in the .NET Core 2.1 release notes. Related instructions, known issues, and workarounds are included in the releases notes. Please report any issues you find in the comments or at dotnet/core #1614
Thanks for everyone that contributed to .NET Core 2.1. You’ve helped make .NET Core a better product!
.NET Core 2.1 will be a long-term support (LTS) release. This means that it is supported for three years. We recommend that you make .NET Core 2.1 your new standard for .NET Core development.
We intend to ship a small number of significant updates in the next 2-3 months and then officially call .NET Core 2.1 an LTS release. After that, updates will be targeted on security, reliability, and adding platform support (for example, Ubuntu 18.10). We recommend that you start adopting .NET Core 2.1 now. For applications in active development, there is no reason to hold off deploying .NET Core 2.1 into production. For applications that will not be actively developed after deployment, we recommend waiting to deploy until .NET Core 2.1 has been declared as LTS.
There are a few reasons to move to .NET Core 2.1:
We had many requests to make .NET Core 2.0 an LTS release. In fact, that was our original plan. We opted to wait until we had resolved various challenges managing platform dependencies (the last point above). Platform dependency management was a significant problem with .NET Core 1.0 and has gotten progressively better with each release. For example, you will notice that the ASP.NET Core package references no longer include a version number with .NET Core 2.1.
- Long-term support.
- Superior performance and quality.
- New platform support, such as: Ubuntu 18.04, Alpine, ARM32.
- Much easier to manage .NET Core and ASP.NET Core versions in project files and with self-contained application publishing.
.NET Core 2.1 is supported on the following operating systems:
Note: The runtime ID for Alpine was previously alpine-3.6. There is now a more generic runtime ID for Alpine and similar distros, called linux-musl, to support any Linux distro that uses musl libc. All of the other runtime IDs assume glibc.
- Windows Client: 7, 8.1, 10 (1607+)
- Windows Server: 2008 R2 SP1+
- macOS: 10.12+
- RHEL: 6+
- Fedora: 26+
- Ubuntu: 14.04+
- Debian: 8+
- SLES: 12+
- openSUSE: 42.3+
- Alpine: 3.7+
Chip support follows:
Note: .NET Core 2.1 is supported on Raspberry Pi 2+. It isn’t supported on the Pi Zero or other devices that use an ARMv6 chip. .NET Core requires ARMv7 or ARMv8 chips, like the ARM Cortex-A53.
- x64 on Windows, macOS, and Linux
- x86 on Windows
- ARM32 on Linux (Ubuntu 18.04+, Debian 9+)
If you are new to Raspberry Pi, I suggest the awesome Pi resources at AdaFruit. You can buy a Pi there, too.
Major thanks to Samsung and Qualcomm for investing heavily on .NET Core ARM32 and ARM64 implementations. Please thank them, too! These contributions speak to the value of open-source.
.NET Core Tools
.NET Core now has a new deployment and extensibility mechanism for tools. This new experience is very similar to and was inspired by NPM global tools. You can create your own global tools by looking at the dotnetsay tools sample.
.NET Core tools are .NET Core console apps that are packaged and acquired as NuGet packages. By default, these tools are framework-dependent applications and include all of their NuGet dependencies. This means that .NET Core tools run on all .NET Core supported operating system and chip architecture by default, with one set of binaries. By default, the dotnet tool install command looks for tools on NuGet.org. You can use your own NuGet feeds instead.
At present, .NET Core Tools support two installation models:
Installation of tools without the -g or –tool-path parameters isn’t yet supported. We’re working on various forms of local tools installation, at which point you’ll be able to install tools without those parameters.
- Global install, which requires the -g or –global parameter to install. Globally installed tools are copied to a specific location in your user profile that has been added to the path. They can be invoked directly, enabling the experience you see above, with direct use of “dotnetsay”.
- Ad-hoc install, which requires the –tool-path parameter to install. Ad-hoc installed tools are copied to a location of your choosing, wherever –tool-path points to. They can be invoked via full path or you can add add the –tool-path location to your path, enabling a similar but custom configuration of global install.
We expect a whole new ecosystem of tools to establish itself for .NET. @natemcmaster maintains a list of dotnet tools. You might also check out his dotnet-serve tool.
The following existing DotNetCliReferenceTool tools have been converted to in-box tools.
Remove project references to these tools when you upgrade to .NET Core 2.1.
- dotnet watch
- dotnet dev-certs
- dotnet user-secrets
- dotnet sql-cache
- dotnet ef
Build Performance Improvements
Improving the performance of the .NET Core build was perhaps the biggest focus of the release. It is greatly improved in .NET Core 2.1, particularly for incremental builds. These improvements apply to both dotnet build on the command line and to builds in Visual Studio.
We added long-running servers to the .NET Core SDK to improve the performance of common development operations. The servers are additional processes that run for longer than a single dotnet build invocation. Some of these are ports from the .NET Framework and others are new.
The following SDK build servers have been added:
The primary benefit of these servers is that they skip the need to JIT compile large blocks of code on every dotnet build invocation. They auto-terminate after a period of time. See release notes for more information on finer control of these build servers.
- MSBuild worker processes
- Razor server
Runtime Performance Improvements
See Performance Improvements in .NET Core 2.1 for an in-depth exploration of all the performance improvements in the release.
Networking Performance Improvements
We built a new from-the-ground-up HttpClientHandler called SocketsHttpHandler to improve networking performance. It’s a C# implementation of HttpClient based on .NET sockets and Span<T>.SocketsHttpHandler is now the default implementation for HttpClient. The biggest win of SocketsHttpHandler is performance. It is a lot faster than the existing implementation. It also eliminates platform-specific dependencies and enables consistent behavior across operating systems.
See the .NET Core 2.1 release notes for instructions on how to enable the older networking stack.
Span<T>, Memory<T>, and friends
We are entering a new era of memory-efficient and high-performance computing with .NET, with the introduction of Span<T> and related types. Today, if you want to pass the first 1000 elements of a 10,000 element array, you need to make a copy of those 1000 elements and pass that copy to your caller. That operation is expensive in both time and space. The new Span<T> type enables you to provide a virtual view of that array without the time or space cost. Span<T> is a struct, which means that you can enable complex pipelines of parsing or other computation without allocating. We are using this new type extensively in corefx for this reason.
Jared Parsons gives a great introduction in his Channel 9 video C# 7.2: Understanding Span. Stephen Toub goes into even more detail in C# – All About Span: Exploring a New .NET Mainstay.
Brotli is a general-purpose lossless compression algorithm that compresses data comparable to the best currently available general-purpose compression methods. It is similar in speed to deflate but offers more dense compression. The specification of the Brotli Compressed Data Format is defined in RFC 7932. The Brotli encoding is supported by most web browsers, major web servers, and some CDNs (Content Delivery Networks). The .NET Core Brotli implementation is based around the c code provided by Google at google/brotli. Thanks, Google!
Brotli support has been added to .NET Core 2.1. Operations may be completed using either the stream-based BrotliStream or the high-performance span-based BrotliEncoder/BrotliDecoder classes.
New Cryptography APIs
The following enhancements have been made to .NET Core cryptography APIs:
Windows Compatibility Pack
- New SignedCms APIs — System.Security.Cryptography.Pkcs.SignedCms is now available in the System.Security.Cryptography.Pkcspackage. The .NET Core implementation is available to all .NET Core platforms and has parity with the class from .NET Framework. See: dotnet/corefx #14197.
- New X509Certificate.GetCertHash overload for SHA-2 — New overloads for X509Certificate.GetCertHash and X509Certificate.GetCertHashString accept a hash algorithm identifier to enable callers to get certificate thumbprint values using algorithms other than SHA-1. dotnet/corefx #16493.
- New Span-based cryptography APIs — Span-based APIs are available for hashing, HMAC, (cryptographic) random number generation, asymmetric signature generation, asymmetric signature processing, and RSA encryption.
- Rfc2898DeriveBytes performance improvements — The implementation of Rfc2898DeriveBytes (PBKDF2) is about 15% faster, based on using Span-based. Users who benchmarked an iteration count for an amount of server time may want to update iteration count accordingly.
- Added CryptographicOperations class — CryptographicOperations.FixedTimeEquals takes a fixed amount of time to return for any two inputs of the same length, making it suitable for use in cryptographic verification to avoid contributing to timing side-channel information. CryptographicOperations.ZeroMemory is a memory clearing routine that cannot be optimized away via a write-without-subsequent-read optimization.
- Added static RandomNumberGenerator.Fill — The static RandomNumberGenerator.Fill will fill a Span with random values using the system-preferred CSPRNG, and does not require the caller to manage the lifetime of an IDisposable resource.
- Added support for RFC 3161 cryptographic timestamps — New API to request, read, validate, and create TimestampToken values as defined by RFC 3161.
- Add Unix EnvelopedCms — The EnvelopedCms class has been added for Linux and macOS.
- Added ECDiffieHellman — Elliptic-Curve Diffie-Hellman (ECDH) is now available on .NET Core via the ECDiffieHellman class family with the same surface area as .NET Framework 4.7.
- Added RSA-OAEP-SHA2 and RSA-PSS to Unix platforms — Starting with .NET Core 2.1 the instance provided by RSA.Create() can always encrypt or decrypt with OAEP using a SHA-2 digest, as well as generate or validate signatures using RSA-PSS
When you port existing code from the .NET Framework to .NET Core, you can use the Windows Compatibility Pack. It provides access to an additional 20,000 APIs, compared to what is available in .NET Core. This includes System.Drawing, EventLog, WMI, Performance Counters, and Windows Services. See Announcing the Windows Compatibility Pack for .NET Core for more information.
The following example demonstrates accessing the Windows registry with APIs provided by the Windows Compatibility Pack.