When using VS to write c# code, it is generally possible to double-click the exe file in the debug file to execute it, but sometimes you need to send this exe file to others for use. The exe file can be executed on your own computer, but on other people’s computer Sometimes an error will be reported after opening, indicating that the .neta operating environment is missing, and the .net environment needs to be downloaded separately.
So I thought about whether I can send an installation package directly when I want to send a program to others. No matter what the system is, the installation package will automatically download the required .net environment during installation, and VS does not provide the function of directly generating the exe installation file by default. I searched the Internet for a long time, and finally found a convenient and easy-to-use software Advanced Installer, which can directly package the exe file generated by vs and the required environment into an exw installation package. Software download link https://download.csdn.net/download/qq_20222919/87780646
The following demonstrates how to use the Advanced Installer software to send and package the exe file generated by C#. First download the Advanced Installer software, and then unzip it.
This software can be used directly after decompression without installation. After the software is ready, start preparing the C# files to be packaged.
Here is an example of a simple test sub-window pop-up to demonstrate.
In VS point generate – generate solution.
At this time, three files will be generated in the debug folder. Next, use the Advanced Installer software to package the exe executable file. Open the Advanced Installer software.
After opening, select New, select .NET application in the template on the right, and then click Create Project in the lower right corner.
Fill in the application name and organization name in the pop-up interface.
The name of this application is the name of the directory where the exe executable file is located after the final installation is completed, and the name of this organization is the name of the folder on the upper level. Fill it in here according to your own situation.
Select the next page after filling out.
Select the type of installation package, here select the exe installation file. Then click Next.
Select the path where the installation package is generated, and click Next. Here you need to add the path of the exe file that needs to be packaged.
The path here is to select the debug directory where C# generated the exe file just now.
After selecting the directory, click Next.
Go ahead and click on the next page.
Go ahead and click on the next page.
Here, select the minimum version and installation system of .net installation. If you want to be compatible with more systems, choose a lower version of .net.
The supported operating system can also be selected according to the actual situation, and
then click the next page after setting.
Set the highest version of .net supported here, and generally use the default value. Click on the next page.
Click directly
on the next page to select the installation interface, and choose according to the situation. After selecting, click Next.
Select the installation language and click Next.
Add the license agreement, you can ignore it here, just click the next page.
Click here to finish. At this point, the exe installation package file will be automatically generated.
The prompt box at the bottom shows that the construction is complete, which means that the installation package file has been generated. Go directly to the installation package generation directory to find the generated installation file.
At this point, the code written in C# has been packaged into an installation file. At this time, you can close the Advanced Installer software.
Next, verify whether the installation file can be installed normally, and click the my_test.exe file directly to install it.
This installation interface is the interface selected when packaging just now.
This installation path is also the path set in the packaging interface just now, just click Next.
Click Install
After the installation is complete, you can open the installation directory to view the installed files.
Double-click the exe file to open and run it.
This has the same effect as running in vs, indicating that the program has been installed successfully. If you want to uninstall the program, just go to the control panel to uninstall it.