.NET6 standalone mode deployment application (no need for the client to install a specific version of the .NET runtime)

The picture below must be familiar to .NET developers, especially the CS architecture. Customer computers need to run programs developed based on .NET. Whether using C#, VB.NET, or F#, the running environment of the released program needs to be corresponding. version of the .NET runtime, otherwise the application will not run properly.
Insert image description here

Under the BS architecture, the workload of installing the specified version of .NET runtime on the server is negligible. Just imagine, if it is a CS architecture and a large-scale commercial software, the client computer system may have it from XP to Win11. If the client computer does not have a specified version of .NET runtime, the program will not run normally. Even if the user is guided to install automatically through the program, there may still be a risk of installation failure, which is fatal to the release of commercial software and the user experience. This has also become a major problem when choosing a technical path for many commercial desktop software. concern.

The good news is that with the release of .NET6 and the blessing of Visual Studio 2022, these will become history. As shown below:
Insert image description here

If you select "Independent" for the deployment mode in the publishing settings, the deployed application itself will contain the corresponding version of the .NET runtime and does not require the user to install the file. In the publishing options, check "Generate a single file" and the application will be published
. After the application is completed, most of the DLLs referenced will be packaged into exe and invisible to the user;
checking ReadyToRun can also improve the program startup speed to a certain extent. For the implementation principle and advantages and disadvantages of ReadyToRun, please refer to the following Microsoft Official documentation:
https://learn.microsoft.com/zh-cn/dotnet/core/deploying/ready-to-run

The figure below is a comparison of the generated project file structure using the independent mode + generate a single file option deployment and the regular mode deployment. It can be seen that the independent mode deployment and generated project will be about 200 M larger, and the larger amount should be the .NET runtime. , although the published project file is 200M larger, there is no need for the client to install the specified version of .NET runtime, which greatly improves the development experience and user experience. The
"Generate a single file" option also makes the application project The structure looks cleaner.

Insert image description here

Guess you like

Origin blog.csdn.net/weixin_40671962/article/details/128372143