头图

Hello everyone, after many months of iteration, the official version of .NET 6 meets you as scheduled! Have you installed it yet? Or wait for the party? Hope that after reading this article you will know more about .NET 6.

Since the announcement of open source on November 12, 2014, .NET has become a cross-platform, multi-scenario-oriented technology. In other words, you can install .NET on traditional Windows, or you can install .NET under Linux and macOS and develop cloud native, desktop, mobile applications, big data, machine learning, games, and the Internet of Things. This update also revolves around these scenarios to empower different industries.

160d0120bd120e1aa2284d707cc82202.png

.NET 6 is an LTS version, which means that in addition to stable use, you can also get security and patch updates. According to the information on the .NET official website, .NET 6 will be maintained until November 2023, so everyone can use it with peace of mind.

673f3a5559535c3a98579be5cc301a1e.png

If you have not yet installed / are ready to install .NET 6, please click on the following link:
https://aka.ms/InstallD

7d85ecd7991e405295343fa4a8414a0e.png

There are many updates to .NET6, and there are many highlights for different application scenarios. Here are some generalizations:

Minimal API

Minimal API is another way to build HTTP services. In .NET 6 projects created through web templates will use Minimal API. One point needs to be explained here: Minimal API will not replace the familiar MVC framework. If your application wants to build an API, it is recommended to use a web template to build it. But if you need more things related to ASP.NET pages, it is recommended to use MVC templates.

dotnet new web -o webapidemo

Look at the default Program.cs program structure

var builder = WebApplication.CreateBuilder(args); 
var app = builder.Build();
app.MapGet("/",()=>"Hello World!"); 
app.Run();

You can quickly complete an API function with four lines of code. Of course, you can add MVC modules, verification modules, etc. based on your needs, depending on the needs of the project.

more information about Minimal API, please visit the following website:
https://aka.ms/LearnDN001

3fe3fc9c17e06df4ee01c17f964596c5.png
(Scan the code for more Minimal API information)

Hot update

Before the previous release of the closed version, hot updates became a hot topic. As a commercial company, Microsoft is able to meet the requirements of the community and it is very commendable that Microsoft retains the needs of the community for .NET 6. This is also a good thing for Microsoft to contact the open source community.

Let’s get to know the hot update first. The earliest hot update is mainly for mobile applications, especially the most common way to update iOS applications. Many developers use dynamic code distribution, which can fix bugs and release functions without releasing a new version, allowing developers to bypass Apple’s review mechanism and avoid long waiting periods for review and multiple rejections. the cost of. I remember that the hot update scene for .NET applications is also under Xamarin. Slowly everyone hopes that if the code can be written to achieve hot update, the compilation time can be reduced, that is, what you see is what you get.

In .NET 6, you can do it through Visual Studio 2022 under Windows, or you can do it through CLI.

Executing related HotReload through the command line is very simple, you only need to execute a command in the corresponding project to implement HotReload for your web application

dotnet watch run

Of course, you can also stop the function of HotReload with the following command

dotnet watch run --no-hot-reload

262865a920fcac6671e344be29bab975.png

more information about .NET CLI HotReload, please visit the following website
https://aka.ms/LearnDN002

906ed8698a5342c662599d5f855be9be.png
(Scan the code for more information about .NET CLI HotReload)

MAUI

Regarding MAUI, my feelings for it are very deep, from the early monotouch to Xamarin, and then to the current MAUI. Some people will think that Microsoft has abandoned Xamarin, but I think that the complete integration into .NET 6 is exactly the performance of Microsoft attaching importance to Xamarin. I remember that I discussed the architecture of MAUI on Reactor's .NET Day in July, and you will find that it is .NET 6 The most important ring.

8afd3d3d8139d28c3b92558d3e3440da.png

You can directly build your MAUI project through the command ⏏

dotnet new maui -o mauidemo

From a lot of information, you can learn that MAUI repackages Xamarin's controls to achieve higher performance. But I want to review with you that there was a feature that I liked when MAUI was released at the time, that is, Debug MAUI on Visual Studio Code. This benefited from the new project structure, but more importantly, it finally made the development of MAUI even more extreme. Guest. But the official version of MAUI has not been released yet, but I found a similar project on Github to give you a first experience ( https://github.com/Clancey/vscode-comet)

more information about MAUI, please visit the following website
https://aka.ms/LearnDN003

ca69a211e81c727d37b701dde172cdfc.png
(Scan the QR code for more MAUI information)

About workload

With the increase of .NET application scenarios, different users need different support. For example, I focus on MAUI applications. At this time, I need the support of iOS, macOS, and Android, but there is no related SDK by default. Additional. Because if all the functions of the scene are merged into the SDK, it will become a giant, and it will be very troublesome from compilation to deployment. The .NET team is committed to maintaining the small and sophisticated SDK, and has added a workload in .NET 6 for different scenarios to tailor it for different scenarios.

When I pass dotnet new maui, there is no new maui template by default, and there will be no related SDKs. At this time, the system will teach you to find out whether there is an official or local template. .

e39612c6c7ae3d0a261c902411eb12e5.png

Do the following through the command line

dotnet workload install maui

You can install the SDK required by MAUI and add a template based on dotnet new maui, which is really convenient and user-friendly, which can reduce some unnecessary installations of the .NET SDK, which is great.

d97fbc94d6cbd7e0b7896626f77d6ca5.png

You can view the related workloads by executing the following statement

dotnet workload search

e972040d31e447cbdeb6ad2d0bde1b95.png

The current scenes have scenes for MAUI and Blazor. Hope that more scenes will be added in the future to meet more needs.

more information about dotnet workload, please visit the following website
https://aka.ms/LearnDN004

afc00d07d8d35f1efbd9c14968d1ea0b.png
(Scan the code for more dotnet workload information)

About machine learning

I have devoted a lot of time to machine learning in recent years, and I am also committed to bringing more machine learning knowledge to .NET developers. When it comes to machine learning under .NET, I believe many people already know ML.NET, but I always recommend the open source TensorFlow.NET.

(https://github.com/SciSharp/TensorFlow.NET)

After several years of development, this project has now provided a good solution for .NET in the field of deep learning. This time through .NET 6, Microsoft has brought more scenarios, such as TorchSharp.

https://github.com/dotnet/TorchSharp)

This is a project under dotnet open source. It refers to the way of TensorFlow.NET and realizes the native .NET PyTorch framework by binding the PyTorch underlying C++ API. I believe that in the future, you can use different deep learning frameworks like Keras in deep learning scenarios under ML.NET.

more knowledge about .NET machine learning, please visit the following website
https://aka.ms/LearnDN005

b5b12f5e6060a29f50f0800755b369a3.png
(Scan the QR code to view more .NET machine learning information)


.NET 6 has many updates, including in Blazor, in performance, in C# 10.0, etc. I will not introduce them to you one by one here. If you are interested, please click the link below to view.
https://aka.ms/LearnDN006
00b8a83e4ff37b7b7ae710924050534c.png
(Scan the QR code for more .NET 6 updates)


微软技术栈
418 声望994 粉丝

微软技术生态官方平台。予力众生,成就不凡!微软致力于用技术改变世界,助力企业实现数字化转型。