NET Core 3.1 has been in use for a long time. In fact, Microsoft will no longer provide support at the end of 2022. The later LTS version. NET 6 will also expire support in November 2024, so upgrading directly to. NET 8 is the best choice.
微软官方推出了升级工具:Upgrade Assistant 。
With the upgrade tool, upgrading becomes very simple. This article describes using the upgrade tool to upgrade a. NET Core 3.1 project to. NET 8.
Install the Upgrade Assistant
Make sure that VS 2022 has been upgraded to 17.8 first. Then install the extension in Extension Management of VS 2022:. NET Upgrade Assistant. Special attention is that if you have installed the Upgrade Tool extension before, you need to uninstall and reinstall it.

upgrade project
In a solution for. NET Core 3.1, there will be many projects that will be upgraded one by one from the lowest level according to their dependencies.
- After installing the upgrade tool, right-click on the project and the Upgrade button will appear:

- Select the upgrade method in the pop-up window:

- Select the target version to upgrade. Here I choose. NET 8. This is a long-term supported version. The latest version of the upgrade tool only supports upgrades to 7 and 8. If you need to upgrade to. NET 6, you need to use the old version:

- Select the content that needs to be updated, select all by default, and click "Upgrade selection" to upgrade:

- You will soon see a prompt indicating that the upgrade was successful:

compilation
I have verified several lower-version projects that no errors occurred during the upgrade process using the tool, but various problems occurred when code compilation was completed after the upgrade.
Question 1: Ionic.zip
In the original version, www.example.com was used for zip compression in the project. Now that.NET8 is no longer supported, you need to replace it with DotNetZip:

Question 2: BinaryFormatter is outdated
Binary serialization is used in many places in the code, but BinaryFormatter has been deprecated in. NET8. There are two solutions:
Modify the source code and replace it with a new recommended method.
Modify the project file, ignore this problem, and add the following configuration to the project file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
...
<NoWarn>$(NoWarn);SYSLIB0011</NoWarn>
</PropertyGroup>
</Project>
Reference: https://www.example.com
Question 3: Aspose usage issues
The Aspose suite is used to process Office files in the project. If the upgraded version has compatibility issues, it will be enough to upgrade to the corresponding version.

Question 4: Method ambiguity
In previous versions, if List stored a complex type, there was no way to directly delete duplication according to a certain field in the type:
List<UserInfo> list = new List<UserInfo>();
list.Add(new UserInfo() { Name="oec2003",Age=18});
list.Add(new UserInfo() { Name = "oec2003" ,Age=18});
list.Add(new UserInfo() { Name = "oec2004" ,Age=18});
list.Add(new UserInfo() { Name = "oec2004" ,Age=18});
var distnctList = list.DistinctBy(x=>x.Age);
foreach (var item in distnctList)
{
Console.WriteLine(item.Name);
}
public class UserInfo
{
public string Name { get; set; }
public int Age { get; set; }
}
The DistinctBy method in the above code is not available in. NET Core 3.1, so we extended a DistinctBy method. Unexpectedly, it was already provided by default in. NET8, which would lead to method conflicts. We just need to remove our extended method and use the default.

run
After solving the above compilation problems, the program can start and run normally. The whole process is still very fast. I have to say that Microsoft's technology is very good for backward compatibility. Coupled with the support of tools, there is no pressure or burden to upgrade to the new version.
In contrast, although some other technologies are constantly updating and iterating, the mainstream still uses a specific version.