I believe many people have installed Program Currently, Installshield is the most comprehensive feature, but the InstallShield syntax is hard to learn.
The installation and deployment of vs.net is short and concise, and the C # syntax is used. For general C # developers, it is very easy to use. After some research on it, it is found that the installation and deployment of vs.net
The functions of the project are also very easy to use, and can be easily implemented by general program installation. Of course, some defects are also found during the study, which will be mentioned later. The following describes ASP. NET security.
Some complex application implementations of the installation and deployment project: first, assume that there is a completed web project ehrm, 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, respectively Code Install and deploy the six Editors:
1,
File System Editor, which is mainly used for File Installation on the target machine.
2,
Registry Editor, used for registry operations on the target machine.
3,
File Type Editor, used to install a new file type to 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 related installation processes such as the product name (ehrmsetup), product code (productcode), and localization of the installation package.
Order attribute. In addition to the ehrmsetup installation and deployment project, we also need to add an ehrmsetupcompenent project to customize the installation operation in
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 a project during installation and deployment
For operations defined by ehrmsetupcompenent, you must add the ehrmsetupcompenent primary output and the ehrm of the project to the project ehrmsetup.
The specific operation is to right-click the ehrmsetup project and choose add> project output.
-- Select the primary output of the project ehrmsetupcompenent.
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:
Minute
Do not set the customactiondata attribute of the four primary outputs to/logicdir = [targetdir]
/Vitualdir = [targetvdir] [targetdir] and [targetvdir] are built-in attributes of system deployment, indicating the installation of the physical directory address and virtual
Directory address. 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.