Getting started with. Net Packaging

Source: Internet
Author: User

1. Some images or files used during the creation of the installation package, such as shortcut keys, in the installation procedure, the background images of each graphic interface must be added to the [Application folder] in advance, that is, the images must be added to the installation project, the file seems to be copied to all the files under debug in the solution, such as EXE, config, RPT, and images.

2. the execution time of the install method in the installation package is: after all the files are installed, execute the number. For example, if the client is installed after the configuration file is installed, but the configuration section does not have information yet, it will be available after the value is assigned in the code, and there will be the same server, for example, if the database is the same, copy it to the client computer and then execute the code in install ,. Obtain the database file on the hard disk, create it in the database, and reference the database file.

 

First, add necessary files to the installation project. It seems to be all the files in the debug folder of the application, as well as the image files used to install the system.

2. Add a Required System: Right-click the installation project and choose Properties> select required system,
Required: [Data Access Component], [. NET 2.0], and [Windows Installer 3.1]. If the application contains RPT reports, the report engine must be added.
Select the second installation location for [specify the installation location of required system components] and [download required system components from the same location as my application]

(3) Select the application folder. Right-click to add a project output item. Set the application as the primary output

Third, add the uninstall program
Open the system directory c: \ windows \ system32to find the msiexec.exe file and copy it to the application folder in the file system view of the newly created installation project.

4. Create the [user's 'project' menu (including installation and uninstallation )]

First, create a folder and then create the following two in the folder, because this folder is installed and uninstalled in the Start Menu> program> the folder.
1. Create an uninstall shortcut key (select a program first and then configure attributes ):

Select the user's 'project' menu, right-click the blank area in the middle, and choose create shortcut key. Choose msiexec.exe, right-click the shortcut key, select properties, and modify the name and icon. Then, configure the arguments attributes..
To configure the arguments attribute, click "Install Project", click "OK", find the productcode, copy it, And then arguments =/X productcode (note that there is a space here ).

2. Create an installation shortcut key (select a program first and then configure attributes ):
Select the user's 'project' menu, right-click the blank area in the middle, and choose create shortcut key. Choose [Application EXE file], right-click the shortcut key, select properties, and modify name. and icon, the arguments attribute is not required for installation.
3. Repeat Step 1 in user desktop.

5. Add User Interface
Right-click the installation project and choose View> User Interface:
The installation process is nothing more than start-> progress-> end
Add a text box A to start and move it to the installation folder (the installation program runs in the above Order)
-> Right-click the [text box A] and enter the value.

6. Add a custom operation

Add a class library project for the installation solution and delete class1.cs
Add an installer class to the class library project-> installer1

7,
Complete the installation process by connecting our custom installation classes:

1. Add the new class library as the main output to the installation project.
Select application folder, right-click in the blank area, and select Add project output. The new class library is set as the main output.
2. Open the "Custom operation View" of the installation project and right-click the corresponding node (such as installation, uninstallation, and rollback) to add the custom operation "Select Main output".
Right-click customactiondata and choose]
/Password = [Password]/username = [username]/Server = [server]/targetdir = "[targetdir] \"
(Note:/targetdir = "[targetdir] \" passing the installation directory path and [Password] Are the attributes of the text box we set on the user interface)

8. Repeat the newly created class library and add the method to it.
1. Rewrite the installation function public override void install (system. Collections. idictionary statesaver)
2. Override the unmount function public override void uninstall (idictionary savedstate)
3. Function protected override void onafterinstall (idictionary savedstate)

Complete

Additional: if we want to retain some files when the program is uninstalled, We need to configure the attributes of these files as follows: that is, permanent is true.
During the installation process, some image files or RPT files in the application (not the installation solution) should be placed in the installed folder.
Copy an attribute of these files in the application to the output directory. The attribute is:
"Copy if it is newer" or "always copy", and add the "content file output" of the winfrom project to the installation package. The file is automatically copied to the installation package during installation.

Additional 2. Uninstall Method 2: (recommended)
1. Complete the installation package, and write down the productcode (select the solution Resource Manager root directory, such as setup1, and then view the properties
Tag, not the attribute in the right-click ).
2.use vs.netto create a new console program uninst.exe File
'Power by: landlordh
'For 2000, XP, 2003
Module uninstall
Sub main ()
Dim myprocess as process = New Process
If system. environment. osversion. tostring. indexof ("nt 5") then
Myprocess. Start ("msiexec", "/X {2b65d4a9-c146-4808-ab4b-321fb077955
9} ") 'to your own productcode
End if
Myprocess. Close ()
End sub
End Module
3.add the exefiles in the binlog of the console program to the package program file, and create the uninst.exe shortcut in the program group.
Method

 

3. You can create a winform program in the class library project and call it in the installation class. Because we add a text box A in the installation project to change the config file, then we can create a winform project to achieve the same effect and provide a better interface.

To upgrade the version of the installation package, you must set the vesion attribute and productcode attribute each time you upgrade the package. You must also set the property of the uninstall icon, otherwise, you will be prompted to delete it in the control panel when you install it again, and the version number will be higher than the previous version number each time you upgrade it. Otherwise, you will be prompted that you cannot install it, in this case, you can only manually uninstall the application on your computer and then install it.

 

<Thank You For Your summary>

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.