C # full record of the packaging and Installation Process

Source: Internet
Author: User
Tags microsoft website

This article is based on the online articles and the actual packaging process.

Development Platform: Chinese version of VisualStudio2005.

The procedure is as follows:

1. Create an installation wizard project or installation and deployment project

Create a project> other project types> installation and deployment> Installation Wizard (or installation and deployment), for example, setup.

2. There are two ways to import the project to be packaged to this installation project:
First, automatic mode. Right-click solution> Add> existing project> select the project you want to package, and then add the project to the solution,
Right-click the installation project setup and choose "add"> "project output"> "main output". In the project drop-down list, select the project you just added, if this option is selected, the basic file of the project to be packaged is added to the application folder on the left. The main output is from ** (activity ).
Second, manually, right-click the application folder on the left (this folder is the file needed in the project to be packaged)-> Add-> file or folder, mainly exe files and other configuration files or data files.

In the first method, the system automatically adds the dependencies of the project to be packaged to "detected dependencies", such as Microsoft..
In the second method, you need to manually add the dependency, right-click the project, choose add> merge module, and select the file to be added ,. net Framework is required and is located under: C: \ Program Files \ Common Files \ Merge Modules.

Note that in the first method, if the project to be packaged contains other configuration files or data files, you must manually add them to the application folder.


3. Create a shortcut for the program menu and desktop on the target machine.

Right-click the executable file in the application folder> Create shortcut. After the shortcut is created, you can rename it as a proper Chinese name and paste the shortcut to the user's program menu, generally, you can create a folder in the program menu. Similarly, create another one on the user desktop.

4. Create an uninstall program
There are two ways to create an uninstall program.

First, write your own Code. The Code is as follows:

/// <Summary>
/// Main entry point of the application.
/// </Summary>
[STAThread]
Static void Main ()
{
System. Diagnostics. Process. Start ("msiexec", "/X {C4A3986F-EA12-4194-BB8B-A9777E78A6ED }");
Application. Exit ();
// Application. Run (new Form1 ());
}

Where {C4A3986F-EA12-4194-BB8B-A9777E78A6ED} is the ProductCode property value for the installation project. To view this value, you need to click the name of the installation project in solution, and then view the ProductCode property value in the Properties window (View> attribute window in the menu.

Add the executable file of the code segment to the application folder and point to it on the unmount item.

Second, use msi to implement
In the Application folder on the left, add the c: \ windows \ system32 \ msiexec.exefile, which can be changed to uninstall.exe. Then, follow the steps mentioned above to create a shortcut for the file to be detached and paste it to the user's "program" menu.
In step 3, create a folder in the program menu, so put the file in this folder. Otherwise, after the packaged program is installed, in the start-> program list, there are two shortcuts that seem unrelated. To facilitate identification, change the shortcut name to "Uninstall **" and ** to the software name.
Modify the Argument attribute value of this shortcut to "/x {ProductCode}". For details about how to view ProductCode, see the first method in step 1.

5. Set the properties of the installation project
1) set the path for installing the Installation File
This path is determined by the installation project attribute manufacture and productname, which is "C: \ ProgramFiles \ [manufacture] \ [productname]. You can modify these two attribute values, alternatively, remove the manufacture attribute as follows:
Right-click "application folder" on the left to open the Properties dialog box and remove "[manufacturer]" from the "defaultlocation" path in the property.
2) in solution manager, right-click the name of the installation project> properties. On the properties page that appears, select "system required" and check. Net Framework2.0.
And select "Download essential system components from the same location as me" below ". By default, the first item is downloaded from the website, and the third item is manually added.
3) optional. Set the RemovePreviousVersion attribute of the installation project to True and the InstallAllUsers attribute to True.


6. Generate a solution
Generate-> Generate a solution.

For more comprehensive operations, see the following:
Http://www.microsoft.com/china/MSDN/library/netFramework/netframework/VCSdnnetdepvsredistdeploy.mspx

? Mfr = true
Http://www.java-asp.net/aspnet/200601/t_49903.html
Program for deploying. net platform

In the actual packaging process, I used the first method in step 2 and the second method in step 4. After installing the program, you can find msiexec.exe in the installation directory, but clicking uninstall does not uninstall the program. You need to uninstall the program from the control panel.

Appendix:
To package. Net Framework2.0 to the installer, you need to use the MicrosoftVisual Studio. NET 2005 Bootstrap plug-in PluginInstaller. msi, which can be downloaded from the official Microsoft website and installed. After installing the plug-in, you will find that there are several more files in the directory of the same level of the Installation File.

In addition, select to download. Net Framework 2.0 from the website in step 5. You can view the url address in the following way:
Click the installation project under solution, View> editor> start the project. You can have a. Net Framework item under the START condition on the left, click this item and view the InstallUrl attribute in the Properties window, generally "http://go.microsoft.com/fwlink? LinkId = 9832"
7. installation path strength settings

Choose [File System]-> [application file]-> [properties]-> DefaultLocation = Lu Jin (D: \ Folder \)
Refer:
How do you use C # package an application (installer) [Uninstall a module that has been added. http://bbs.bccn.net/viewthread.php? Tid = 129015.
C # packaging. http://www.cnblogs.com/wenlin1234/archive/2008/01/16/798737.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.