Content Introduction:
Some considerations for customizing the installer
Describes how to obtain custom interfaces and system parameters
describes how to add custom actions during Setup
Some considerations for customizing the Installer:
CustomActionData Property
Additional data for custom actions, read installation information from defined actions
CustomActionData properties with/name=value 's format. Multiple values must be separated by a single space:/name1=value1/name2=value2. If there is a space in the value, it must be quoted:/name= "a value". The
can pass Windows installer properties. For Windows Installer properties that return a directory like [TARGETDIR], you must enclose the parentheses and the trailing backslash:/name= [targetdir]/.
to make a custom action considered an installation component, you must set the InstallerClass property to True
The following are two truncated vs.net2003, some of the system properties that can be referenced for a custom installation:
The
Custom installation needs to create some interfaces, and then get information such as text entry for these interfaces, and the following two diagrams describe how to do this:
the text boxes and check boxes on the way are the custom interfaces that the author adds.
Adds a custom installation action for a custom installation, specifying the project from which the installation is defined, such as installaction.
How to obtain custom interface and system parameters:
Add CustomActionData property data to a custom action.
/connectionstring= "[ConnectionString]"/vdir=[targetvdir]/targetdir= "[targetdir]/"
Referencing the parameter string virtualroot = this in code. context.parameters["VDir"]; Install virtual path
String physicalroot = this. context.parameters["TARGETDIR"]; Install physical path
String connectionString = this. context.parameters["ConnectionString"]; System Database Link string
How to add a custom action during Setup:
Run DOS command
Operations such as creating a virtual directory or installing a database script require a DOS command to be invoked System.Diagnostics.ProcessWindowStyle.Hidden is executing a command without displaying a DOS window
/**////<summary>
Background execution DOS file
</summary>
<param name= "filename" > filename (including path) </param>
<param name= "Argument" > Run parameters </param>
<param name= "hidden" > Whether to hide Windows </param>
private void Rundos (string fileName, string argument, bool hidden)
{
Process process = new process ();
Process. EnableRaisingEvents = false;
Process. Startinfo.filename = string. Format ("/" {0}/"", fileName);
Process. startinfo.arguments = argument;
if (hidden)
{
Process. Startinfo.windowstyle = Processwindowstyle.hidden;
}
Else
{
Process. Startinfo.windowstyle = Processwindowstyle.normal;
}
Process. Start ();
Process. WaitForExit ();
}
To create a virtual directory using the Active Directory DirectoryEntry :
overrides installer functions to implement custom installation and uninstall : public override void install ( System.collections.idictionary statesaver)
{
base. Install (statesaver);
saveconfig (); //Save the configuration file to the file and save it to the database
Setupdb (); //Install SQL Script
installservice (); //Install Windows service
Protected override void onbeforeuninstall (system.collections.idictionary savedstate)
{
Base. onbeforeuninstall (savedstate);
uninstallservice ()//Uninstall Windows service
}
Execute database scripts in a custom installation :/**//// <summary>
/// Execute SQL script
/// </ Summary>
/// <param name= "path" > script file path full name </param>
/// <param name= " UserID > Database login id</param>
/// <param name= "password" > database login password </param>
/// <param name= "Server" > Database server address </param>
private void dosql (String path, String userID, string password, string server)
{
// -u -p The -s -i keyword is case-sensitive
string arguments = string.format (" -u {0} -p {1} -s {2} -i /"{3}/" ", userid, password, server, path);
this. Rundos ("Osql.exe", arguments, false);
}
Log directory Create authorization action :/**//// <summary>
/// Create log directory and authorize [authenticated Users can write
/// </summary>
private void createlogdirandauthorize ()
{
String logdir = this. context.parameters["TARGETDIR"] + "Log";
createdir (LogDir);
string patrollogdir = this. context.parameters["Targetdir"] + "Yourwebdir/log";
createdir (Patrollogdir);
}
/**//// <summary>
/// Create a directory and authorize
/// </summary> based on the specified path and user name,
/// <param name= "Logpathname" > specified directory absolute path </param>
/// <returns></ returns>
Private void createdir (String logpathname)