With the pace of full open source, Microsoft has gradually kept pace. As one of the earliest important software for Microsoft to move towards open source, the release of. Net 5 is of great significance to Microsoft and its users.
Microsoft’s future goal is to integrate all. Net components into one product, and then users can use a part of. Net according to their needs, rather than downloading or installing all content separately.
For visual studio users, visual studio 16.8 or later is required to use. Net 5.0 on windows and the latest version of visual studio for Mac on MacOS. The c# extension of visual studio code also supports. Net 5.0 and c#9.
Net 5.0 is the first version of the. Net unified journey. Microsoft hopes that. Net framework developers can migrate their code and applications to. Net 5.0, laying the foundation for the transition of xamarin developers to a unified platform in. Net 6.0 released next year.
Version release timeline:
. net core 3.0 was launched on September 2019
. net core 3.1 was launched on December 2019 as lts (long term support). After that, the. Net core will be renamed. Net, and the new version will be released every year. The even version number is defined as lts version and the odd version number is current version.
.NET 5.0 2020/11
.NET 6.0 LTS 2021/11
.NET 7.0 2022/11
.NET 8.0 LTS 2023/11
If you are interested, you can experience the published materials and addresses: https://dotnet.microsoft.com/…
. net 5.0 is a combination of. Net framework and. Net core core, aiming to unify. Net platform Net 5.0 undoubtedly represents the future of. Net, but most domestic enterprises still use. Net framework, but in the long run, upgrading seems inevitable.
In order to fully demonstrate the performance of. Net5, Microsoft has carried out extensive internal deployment since the release of the first preview version. In addition to running the. Net website on. Net 5.0, Bing is also using this new platform.
In this update, some significant changes are highlighted, including some performance improvements.
The following are the highlights of this version released by Microsoft:
1.. net 5.0 has been deployed to http://dot.net And http://Bing.com After several months of trusteeship, it has been tested in practice.
2. The performance of many components has been greatly improved Net 5.0 has improved the performance of arm64 and grpc
3. C# 9 and f# 5 provide new language improvements, such as top-level programs and records of c# 9, while f# 5 provides performance improvement of interactive programming and functional programming on. Net.
4. Net library improves the performance of JSON serialization, regular expression and HTTP (HTTP 1.1, http / 2). They are now also fully annotated as nullable.
5. Due to the improvement of GC and layered compilation, p95 latency has decreased.
6. The application deployment options are better, with ClickOnce client application publishing, single file application, reduced container image size, and increased server core container image.
7. The scope of the platform is expanded, and windowsarm64 and webassembly are added.
8. A notable change is that. Net 5.0 applications can run natively on arm64 windows devices, eliminating some performance obstacles caused by simulation. However, in this version, windows desktop components cannot be used for arm64 devices — this is planned in the service update of. Net 5.0.
In recent years, the open source projects of. Net core are also very active. With the release of. Net5, these projects will be gradually integrated into. Net5 and later versions.
However, there are several points that need special attention:
Although the current. Net 5 is strong enough, strictly speaking, it is still in the implementation stage, and. Net 6.0 may be more worth looking forward to.
At present, many upgrades of. Net5 are not discussed in practice, such as regular performance improvement and static regular cache; Kestrel improves communication performance and supports http3; Certificate exchange to enhance SSL communication; The internal application of readonly struct; Httpclient’s humanized API supports webassembly, serialization results, quic, etc; JSON supports field serialization, read-only type serialization, web type serialization, circular reference serialization and other features; GC can allocate no zero memory space, allocate “fixed” lots of space, gcmemoryinfo, etc.
If there is no urgent demand, it is not recommended to upgrade to 5.0 at present. You can use 5.0 as a research springboard and consider upgrading when Microsoft releases the long-term maintenance version of 6.0lts next year to reduce the risk. Of course, this needs to be evaluated according to the actual situation.
next, put a pit that may be encountered when upgrading. Net5 from. Net core 3.1 for reference. If you don’t need it, you can skip this part. The author “dotnet cross platform”.
Previously, Scott Hunter vowed to smoothly migrate. Net core 3.1 to. Net5 on his blog, so he went to upgrade my treasure project on the same day. As a result, there were no big pits and small pits. It took a whole day to complete it. Let’s take a closer look and provide some reference for the construction.
The upgrade project was previously open source on GitHub, and 300star was added a week. Although it was closed for some reason, I personally worked very hard. This is not. Net5 just released, the first time began to upgrade.
The project is a wechat applet mall. The back end is supported by the micro service architecture. Ocelot gateway + consul service registration discovery + core webapi + grpc + identityserver4 are all arranged. The overall situation is still relatively complex. Mongodb, redis and rabbitmq are also arranged. Then, various steps are taken in the process of upgrading. Net core 3.1 to. Net5.
Vs upgrade pit
The first pit of upgrade comes from vs tool upgrade! Before. Net5 preview, RC1 and RC2 all used visual studio 2019 preview. At present, the official version of. Net5 found that it only needed to upgrade visual studio 2019 to v16.8, and then went to upgrade excitedly. The result was a blow: the visual studio installer prompted that the network was not connected and could not be downloaded! Of course, it’s not my network problem. In fact, there is something wrong with DNS resolution (some users will encounter it. The solution is to set the computer’s DNS to 188.8.131.52). After all, it was the early morning of the 11th. I thought that Microsoft’s official synchronization was not enough, so I chose to change tools, go directly to Linux and upgrade with vs code, and then started the second wave of environment pit!
Experience: if the visual studio installer prompts that the network is not connected and cannot be downloaded, you can set the current computer DNS to 184.108.40.206
Linux environment pit
Before vs code development in Linux environment, I was familiar with it. This time I wanted to upgrade. Net5, so I easily changed the Linux system from centos7 to centos8, and then made gorgeous pits. For example, the network card name in centos8 has changed from ens33 to eth0. Nftables is used to replace iptables. Various small changes are difficult to prevent. Then, the commands of the latest version of docker are also slightly different from those before, resulting in various failures in the previously sorted Linux + docker operation notes, which have been tossed back and forth for several hours.
Of course, the environment is just the environment. After tossing, it will pass, and the pit at the level of code migration is the most troublesome, because I don’t know how many have not been found!
. net5 migration pit
It is easy to upgrade the project from. Net core 3.1 to. Net5. Upgrade the SDK version from 3.1 to 5.0 in global.json, and then change the targetFramework from NETCORE app3.1 to net5.0. There are also some class library namespace changes that don’t matter at all. The intelligent tips of the first ide in the universe can be easily solved. However, in the process of real project migration, I encountered various small problems:
1. Swagger is integrated by default in the core webapi framework template project. This is a new one, but there are some custom configurations and extensions in the previous project, which also lead to conflicts.
2. During the upgrade of the third-party Framework version of identityserver4, there are a lot of API changes, and the code can not be changed. Although this pot is not. Net5, it will be encountered in the upgrade project.
3. I took some time to try c#9. I wanted to experience the new syntax and new features, such as native ints, native ints, and pattern matching improvements. As a result, I got involved several times.
4. For the bug found after the project upgrade, the daily value of datetime has changed. In asp.net core 3.1 and earlier versions, datetime is bound to the server local time, while after 5.0, datetime is bound to utctime.