
11 November 11 is the day of e-commerce carnival and the day when .NET5 is officially released. I am anxiously refreshing the Microsoft official website and other updates, and want to start tossing for the first time. Previously, Scott Hunter vowed in his blog: .NET Core3.1 smoothly migrated to .NET5, so he upgraded his treasure project on the same day. The result was that there were no big pits and small pits. It took a day to get it done. Let’s take a closer look. Stroke, provide a point of reference for the construction.
Background introduction
The upgraded project was previously open sourced on Github, and 300 stars were added a week. Although it was closed for some reason, it was considered very diligent. This is not. NET5 has just been released, the upgrade began the first time.
The project is a WeChat applet mall. The backend is supported by a microservice architecture. Ocelot gateway + Consul service registration discovery + Core WebApi + gRPC + IdentityServer4 are all arranged, and the overall is quite complicated. MongoDB, Redis , RabbitMQ are also arranged, and then in the process of .NET Core3.1 upgrade .NET5, various pits.

VS upgrade pit
The first pit of the upgrade comes from the VS tool upgrade! Previously, the .NET5 preview version, RC1 and RC2 used Visual Studio 2019 Preview. At this moment, the official version of .NET5 found that only Visual Studio 2019 needs to be upgraded to V16.8, and then it was upgraded enthusiastically. A hit: Visual Studio Installer prompts that the network is not connected and cannot download! Of course it’s not a network problem. In fact, it’s a problem with DNS resolution (some users will encounter, the solution is to set the computer’s DNS to 8.8.8.8), but after all, it was the early morning of the 11th, thinking that the official Microsoft synchronization was not enough , After choosing to change tools, go directly to Linux to upgrade with VS Code, so there is the second wave of environmental pits below!
**Experience: **If you encounter the Visual Studio Installer prompting that the network is not connected and unable to download, you can set the current computer DNS to 8.8.8.8.
Linux environment pit
Before the development of VS Code in the Linux environment, I was quite familiar with it. This time I was thinking about upgrading .NET5, so I conveniently changed the Linux system from CentOS7 to CentOS8, and then there were gorgeous pits. For example, the name of the network card in CentOS8 has changed from ens33 to eth0, and nftables is used to replace iptables. Various small changes are hard to prevent. Then the latest version of docker has some small changes from the previous commands, which caused various failures of the Linux+Docker operation notes that were organized before. , Tossing back and forth for several hours.
Of course, the environment is just the environment, and it will pass after the toss. The pits at the code migration level are the most troublesome, because I don’t know how many have not been discovered!

. NET5 migration pit pit
It is very easy to upgrade the project from .NET Core3.1 to .NET5. Upgrade the SDK version from 3.1 to 5.0 in global.json, and then change the TargetFramework from netcoreapp3.1 to net5.0. There are also some class library namespace changes that are completely okay. The smart prompt 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 addition, but the previous project had some custom configurations and extensions, which also caused conflicts.
2
The third-party framework version of IdentityServer4 has been upgraded. There are a lot of API changes, and a lot of code cannot be changed. Although this pot is not .NET5, it is also encountered in the upgrade project.
3
It took some time to try C#9, and I wanted to experience the new features of the new syntax, such as Native ints, Pattern matching improvements, and pattern matching improvements, but I got into it several times.
4
The bug found after the project upgrade, the value of DateTime has changed every day. In ASP.NET Core 3.1 and earlier, DateTime is bound to server local time, and after 5.0, DateTime is bound to UTCTime.
