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.
.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.
If you have not yet installed / are ready to install .NET 6, please click on the following link:
https://aka.ms/InstallD
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
(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
more information about .NET CLI HotReload, please visit the following website
https://aka.ms/LearnDN002
(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.
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
(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. .
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.
You can view the related workloads by executing the following statement
dotnet workload search
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
(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
(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
(Scan the QR code for more .NET 6 updates)
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。