Minbear (dev-club)
I believe that many people have done the installer, and the most complete task of INSTALLSHIELD is currently the most functional, but the installshield's grammatical learning is really hard. It is relatively vs.NET to install short and fine, and use C # syntax, for general C # development It is extremely easy to use it. After some research, it is found that VS.NET installation deployment project has been very easy, and the general program installation can be easily realized, of course, in the process of research Some defects have also found it later.
Let's introduce some of the complex application implementations of the ASP.NET installation deployment project:
First we assume that there is a completed Web project EHRM, and its file list is as shown in the web.config's other configurations of our database connection and system, such as database types, etc., these configurations need to be modified during installation.
OK, I know our installation object, now start to install the deployment program, first, add a new project to the solution, as shown, the project type is a web installation item, the project name EhrmSetup.
The project is added, selecting EhrmSetup, will find some changes in the toolbar, as shown in the figure,
There are main six tool buttons, the 6 major editor for the installation deployment of the code:
1,
Represents a file system editor, mainly used for file installation operations for the target machine.
2,
Represents a registry editor for registry operation for the target machine.
3,
Represents the file type editor to install a new file type to the target machine.
4,
User Interface Editor is used to determine some of the interfaces used during installation.
5,
Customize the operation editor, call the user-defined operational code.
6,
Start the condition editor to set the startup condition for the installer.
These 6 editors are not necessarily all, and our Demo installation only needs to use 1/4/5
Most of the installation package properties are present in the properties of the EHRMSETUP project, the properties interface is as follows:
Here you can set the installer properties related to the product name (EhrmSetup), product number, and the Globalization of the Installation Package (Localization).
In addition to the EHRMSETUP installation deployment project, we also need to add an EHRMSETUPCOMPENT project to add a new installer class from the EHRMSetUpcomplace project, as shown in the figure.
The name is EHRMINSTALLER.CS, adding the following code:
Protected Override Void OnafterInstall (iDictionary SavedState)
{
Base.onafterInstall (SavedState);
}
Public Override Void Install (iDictionary Stateaver)
{
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 code will be mainly responsible for custom processing for operations in the installation, including database, configuring Web.config, etc.
In order to call the project EHRMSETUPCOMPAMPAMPAMPAMPAMPAMPAMPAMPAMPAMPAMPAMPENT, you need to add the primary output of EhrmSetupCompenent in the project EhrmSetup. The specific operation is to select the EhrmSetup project. The main output, after the addition is completed, as shown in the figure:
Now return to the project EhrmSetup, open the file system editor, click the web application folder, edit its properties, the properties interface is as follows:
The more important thing is that the VirtualDirectory property indicates that the virtual directory name established after the installation is determined.
By the user interface editor, the user's installation interface is configured, and the VS.NET2003 is currently available, as shown in the figure:
Basic is a relatively simple configuration window, so if you need to use some complex configurations, these windows are far less than, but we can perform partial extensions to achieve these complex configurations, the specific methods are as follows:
1. Add a Windows window frmconfig.cs in the project EhrmSetupCompene, design the interface we need to use.
2. Modify the code in the EHRMINSTALLER.CS as follows:
Protected Override Void OnafterInstall (iDictionary SavedState)
{
FRMCONFIG _FC = New fmconfig ();
_Fc.showdialog ();
Base.onafterInstall (SavedState);
}
3. This, interrupt and pop up FRMCONFIG will be interrupted during the installation process.
Finally, the custom operation during the installation process is set by the custom operation editor. From the web application folder, select the main output from the EHRMSETUPCOMPENT (Event), and the addition is shown in the figure:
The CustomActionData property of 4 main outputs separately is:
/ Logicdir = [targetdir] / vitualdir = [targetvdir]
[Targetdir] and [Targetvdir] are system deployment self-belt properties, indicating that the physical directory address and virtual directory address are installed.
After setting these custom operations, you can call directly in the code of the EHRMSETUPCOMPENENT project, the calling code is as follows:
Public Override Void Install (iDictionary Stateaver)
{
/ / Install the physical catalog
String logicDir = context.parameters ["logicdir"];
/ / Install the virtual directory
String vitualdir = context.parameters ["vitualdir"];
// TODO action according to the configuration installation
Base.install (StateSaver);
}
The last thing you need is some file processing when you uninstall:
Public override void uninstall (iDictionary savedstate)
{
/ / Install the physical catalog
String logicDir = context.parameters ["logicdir"];
/ / Install the virtual directory
String vitualdir = context.parameters ["Vitualdir"]; // Handling the installation content of the custom section, such as database, etc.
Base.unInstall (SavedState);
}
After completing this series of action, the installation prototype of the entire program has been basically OK, as long as a series of Actions that need to be made in the actual installation can make a complete installation deployment program.
Precautions:
1, the resource file is the source file of the project, not the content file, so if there is a resource file in the project exists, you need to add the source file output of the project, and use the exclusion filter to set the * .cs file and * .resx file Filtering.
2, bin directory is not in a web project, so packaging also needs to join the main output of the web project or directly add files in the bin directory into the web project, which generated DLL will be included in the content file output.
3. Some directories may not be created in the installation and production process (even if the specific reason is not found, it is estimated because of file-dependent), can be created directly in the web application folder.
Level is limited, if you have any questions, welcome to discuss with me Davixiong At Hotmail.com