Microsoft unveils .NET 7 preview 2: Here’s What You Need to Know
Table of contents
In March Microsoft announced the second preview release of .NET 7. The release is focused on bringing improvements to the ‘dotnet new’ Command Line Interface (CLI) experience. This will help developers save time.
Microsoft has introduced a new Regex Source Generator as well. This will help developers precompile their Regex code for a faster startup under certain conditions.
Overall, the improvements introduced in preview 2 are significant from a developer’s point of view. They look encouraging and promising to the developer community, helping them simplify their work processes.
If you want to download Microsoft .NET 7 preview 2 to test out the new features and improvements, you can do it from here. The preview can be downloaded on Windows, Linux, and macOS machines.
How to Install
You can download the installation package from the link mentioned above. Next, you need to run the downloaded installation package. Click Install in the Installation Wizard dialog box. This will begin the installation process. The installation is pretty quick and will be done in no time.
After the installation is complete, click ‘close.’
You have now successfully installed Microsoft .NET 7 preview 2 on your machine.
Now let’s take a look at what’s new in the new Microsoft .NET 7 preview.
New Regex Source Generator
As mentioned earlier, the new Regex Source Generator enables developers to compile their Regex code for faster startup. The Regex Source Generator brings all the benefits from Microsoft’s compiled engine. However, there is no startup cost attached.
Moreover, the generator provides additional benefits. For instance, the new regex source generator improves the debugging experience and is also trimming-friendly.
To start using the new Regex Source Generator, you only need to change the containing type into a partial one. Next, you have to declare a new partial method using the RegexGenerator attribute. This will return the optimized Regex object.
As you make changes to your code, the generator will automatically fill the implementation of the method. The changes will also get updated as you do it.
The .NET 7 preview 2 brings new updates and improvements to the Software Development Kit (SDK). The dotnet new command’s interface has been changed. It has been given a more consistent and intuitive interface for various subcommands that developers already use.
Additionally, support for tab completion of template options and arguments has been updated significantly. It now gives quick feedback to the developers on valid arguments and options as they type.
Lastly, all of the commands in the help output no longer have the —- prefix. This is in line with the developers’ expectations from the subcommands in a CLI application. The earlier versions, such as —-install, are still available to the developers. They help prevent breaking developer scripts. However, Microsoft plans to add obsoletion warnings in the future. This will help to migrate developers to the new coding methodologies.
Tab completion has been supported for a while now by the dotnet CLI on popular shells. These include PowerShell, zsh, and fish.
Earlier, individual dotnet commands implemented meaningful completions. However, with .NET 7 preview 2, the new command provides tab completion for;
- Available template names
- Template options
- Allowed values for those template options
That being said, there are still a few known gaps in completion. For instance, the installed language values are still not suggested by the —-language command.
Microsoft is aware of the gaps left to be completed. Thus, they are dedicated to filling the gaps present with future releases. They aim to make enable completions automatic or as simple as possible. For example, they are looking to make completions as a single-line command that developers can execute easily.
They hope to make improvements throughout the dotnet CLI in tab completion. This will significantly help the developer community.
Microsoft .NET 7 will continue to receive support and patches from Microsoft. They will be provided for eighteen months from the date of release and will be entirely free.
Developers should be cognizant that all the releases are the same quality-wise. The difference lies only in the duration of the support.
When it comes to operating systems, .NET 7 preview 2 is compatible with Windows, Linus, and macOS. The architectures supported are AMD x64, Intel x64, ARM, IBM Z, and LinuxONE.
The end of support happens when Microsoft no longer provides updates, patches, or fixes to the version. It is also referred to as the End of Life (EOL) of the product.
English and German
Microsoft has brought breaking changes with every version release of .NET. The same tradition follows with the release of .NET 7 preview 2.
To know the recent breaking changes with the release of preview 2, you can check this link out. The changes are explained in an easy format with detailed explanations. However, the article is a work in progress and keeps getting updated regularly.
If you are interested in finding out the changes under review, you can check this link out.
Microsoft has announced earlier that they were moving the NativeAOT project from the experimental stage to mainline development with .NET 7. They have been working to move NativeAOT from the experimental dotnet/runtimelab repo to the dotnet/runtime repo.
Microsoft is happy to announce that the task to move NativeAOT from dotnet/runtimelab to dotnet/runtime has been completed. But, they are yet to add first-class support in the dotnet SDK. They hope that the task will be completed soon so that developers can try NativeAOT with their apps.
In the meanwhile, developers can try app trimming and make sure that there are no trim warnings. Trimming is an essential part of NativeAOT and, thus, needs to be without any issues.
A Microsoft .NET 7 Target Framework Moniker (TFM) is needed in the project file to target .NET 7. The full set of .NET 7 TFMs, including operating-specific ones, follows.
Microsoft expects the up-gradation to .NET 7 to be simple and straightforward. However, if there are any issues with the upgrade process, please report them to Microsoft.
Microsoft .NET releases contain products, libraries, and runtime, among others. These enable collaboration across multiple teams within and outside Microsoft. If you want, you can learn more about the different Microsoft product roadmaps mentioned below.
The Microsoft .NET 7 preview 2 adds a ton of features and functionalities that prove helpful to the developers. That being said, this is just a preview version and not a stable build. Thus, developers are likely to face issues working with the build. Thus, it is advisable that you install and test the preview 2 version only on non-production environments. A stable release is on its way and will be released soon.