Switch: vs. net installation and deployment

Source: Internet
Author: User

 

Http://www.181it.com/quAnswer_view.asp? Smallid = 16 & id = 24

 

Vs. net installation and deployment

Vs. net installation and deployment

I believe many people have installedProgramCurrently, Installshield is the most comprehensive feature, but the InstallShield syntax is hard to learn. Relatively speaking, the installation and deployment of vs.net is short and concise, and the C # syntax is used, for C # developers, it is very easy to use. After some research on it, it is found that the functions of vs.net installation and deployment projects are also very easy to use, general program installation can be easily implemented. Of course, some defects are also found during the study, which will be mentioned later. The following describes some complex application implementations of the ASP. NET installation and deployment project: first, assume that a completed web project ehrm exists, and its file list

Among them, Web. config contains our database connection and some other system configurations, such as the database type, which need to be modified during installation.
OK. Now that we know the installation object, start to install and deploy the program. First, add a new project in the solution. The project type is Web installation project, and the project name is ehrmsetup.

After adding the project, select ehrmsetup and you will find some changes in the toolbar ,:

There are 6 tool buttons, respectivelyCodeInstall and deploy the six Editors:
1. The file system editor is mainly used for File Installation on the target machine.
2. indicates the Registry Editor used for registry operations on the target machine.
3. File Type Editor, which is used to install a new file type on the target machine.
4. the user interface editor is used to determine some interfaces used during installation.
5. The custom operation editor calls the User-Defined operation code.
6. the startup condition editor is used to set the startup conditions of the installer.
These 6 editors may not all be used. For demo installation, we only need to use 1/4/5. Most of the installation package attributes are stored in the attributes of the ehrmsetup project. The attribute Interface

Here, you can set the attributes of the installation program, such as the product name (ehrmsetup), product code (productcode), and localization of the installation package. In addition to the ehrmsetup installation and deployment project, we also need to add an ehrmsetupcompenent project, use a custom installation operation, and add a new installer class to the ehrmsetupcompenent project,

The name is ehrminstaller. cs. Add the following code to it:
Protected override void onafterinstall (idictionary savedstate ){
Base. onafterinstall (savedstate );
}
Public override void install (idictionary statesaver ){
Base. Install (statesaver );
}
Protected override void onbeforeinstall (idictionary savedstate ){
Base. onbeforeinstall (savedstate );
}
Public override void uninstall (idictionary savedstate ){
Base. Uninstall (savedstate );
}
Public override void rollback (idictionary savedstate ){
Base. rollback (savedstate );
}
These codes are mainly responsible for customizing the operations during installation, including database creation and web. config configuration. To call the operation defined by the ehrmsetupcompenent project during installation and deployment, you must add the primary output of ehrmsetupcompenent and the content output of the ehrm in the ehrmsetup project, the specific operation is to right-click the ehrmsetup project and choose "add"> "project output"> "ehrmsetupcompenent"> "main output ".

Now return to the project ehrmsetup, open the file system Editor, click the web application folder, and edit its properties. The properties page is as follows:

The virtualdirectory attribute indicates the name of the virtual directory created after installation. Other attributes depend on the actual situation. The following uses the user interface editor to configure the user's installation interface. vs. net2003 currently provides fewer windows,

There are several simple configuration windows, so if you need to use some complex configurations, these windows are far from enough, however, we can perform some extensions to implement these complex configurations. The specific method is as follows:
1. Add a Windows window frmconfig. CS to the project ehrmsetupcompenent to design the interface we need.
2. modify the code in ehrminstaller. CS as follows:
Protected override void onafterinstall (idictionary savedstate ){
Frmconfig _ fc = new frmconfig ();
_ FC. showdialog ();
Base. onafterinstall (savedstate );
}
3. In this way, frmconfig will be interrupted during the installation process and pop up for the user to configure. Finally, you can use the custom operation editor to set the custom operations during the installation process. Select the main output from the Web application folder from ehrmsetupcompenent (activity) and add the following items:
Set the customactiondata attribute of the four primary outputs to/logicdir = [targetdir]/vitualdir = [targetvdir] [targetdir] and [targetvdir], which are the built-in attributes of system deployment, indicates the physical directory address and virtual directory address respectively. After setting the input parameters for these custom operations, you can call them directly in the code of the ehrmsetupcompenent project. The call code is as follows:
Public override void install (idictionary statesaver)
{
// Install the physical directory
String logicdir = context. Parameters ["logicdir"];
// Install the virtual directory
String vitualdir = context. Parameters ["vitualdir"];
// Install the SDK according to the configuration.
Base. Install (statesaver );
}
The last thing to do is some file processing during uninstallation:
Public override void uninstall (idictionary savedstate ){
// Install the physical directory
String logicdir = context. Parameters ["logicdir"];
// Install the virtual directory
String vitualdir = context. Parameters ["vitualdir"];
// Process custom installation content, such as databases
Base. Uninstall (savedstate );
}
After completing this series of actions, the installation prototype of the entire program has been basically OK, as long as you add a series of actions required for the actual installation in the corresponding place, you can create a complete installation and deployment Program.
Note:
1. The resource file belongs to the source file of the project, rather than the content file. Therefore, if a resource file exists in the project, you need to add the source file output of the project, and use the exclusion filter to set *. CS file and *. filter resx files.
2. The bin directory is not in the web project by default. Therefore, you must add the main output of the web project or directly add the files in the bin directory to the web project for packaging, the generated dll will be included in the content file output.
3. Some directories may not be created during installation and production (I cannot find the specific cause, probably because of file dependency). You can manually create directories in the Web application folder.

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.