Read app.config file in Installscript
I wanted to learn how to read the connection string from app.config using installshield es, although it is possible to import the XML structure of the app.config file, but the problem is the connection section is updated at runtime.
During the update, I need to get the connection string string to the app.config file, is there a way to implement it.
thanks
a source to share
You can use the Modify Text File feature to update the connection string. Please put a parameter to store the text you want to replace. Below is the support for Installshield:
Project
This information applies to the following types of projects:
Base MSI InstallScript MSI Database MSI Conversion This information does not apply to InstallScript projects; however, InstallScript includes string functions for finding and modifying string variables and literals. You can use these functions in InstallScript projects.
You can use the Windows Installer property to specify the text strings that you search for or replace. You can also use the property to specify text files that you include or exclude in your search.
At runtime, Windows Installer uses MsiFormatRecord to resolve the property value and uses that value to modify your text file. This allows you to take advantage of data that end users enter in dialog boxes or other configuration information that is determined at runtime when your product text files change at runtime.
Example The following procedure demonstrates how to allow end users to specify an IP address during installation, which should be written to the XML-based web.config file at run time. The web.config file is installed with the product in INSTALLDIR and contains XML such as the following:
<appSettings>
<add key="IP Address" value="default" />
</appSettings>
The default value in bold should be replaced with the IP address entered by the end user.
Note that you can substitute a hard coded value using the property for the following replacement set parameters in the Text File Changes window:
Include Files Exclude Files Additionally, you can use the property for the following options for the replacement item in the Text File Changes window:
Find what Replace The property you specify in any of these parameters must be enclosed in square brackets and the property name must be uppercase; for example, [MYPROPERTY].
Step 4 of the procedure differs slightly depending on the type of project because the Windows Installer manages the user interface of the Basic MSI installations, and the InstallScript engine manages the user interface of the InstallScript MSI installations.
Task
For end users to specify an IP address:
In the browse list under System Configuration, click Text File Changes. Add and configure a replacement element that identifies the file you want to search for: Right-click the Text File Change Explorer and click the Add Note Set button. InstallShield adds a new replacement element. Steps 2b-2d explain how to configure its parameters, which are displayed in the right pane.
In the Target Folder setting, select the [INSTALLDIR] directory property. For Include Files, enter the following: web.config
Leave the default values ββfor the other parameters. Add and configure a replacement element that defines the search and replace criteria: In the text file edit explorer, right-click the replacement element that you created in step 2, and then click Add Replacement. InstallShield adds a new replacement element. Steps 3b-3d explain how to adjust its parameters, which are displayed in the right pane.
In the Find menu, enter the following:
For Replace With, enter the following:
Leave the default values ββfor the other parameters. Use the property in the dialog. This part of the procedure depends on what type of project you are using. For basic MSI projects: In the browse list in the user interface, click Dialogues. In the Dialogs Explorer, expand the All Dialogs folder and select a language from the dialog box, which should include a username. Alternatively, you can add a new dialog. Add the "Edit Field" element to the dialog and set the following for the Property property: MYPROPERTY
For MSI InstallScript projects: In the browse list under Behavior and Logic, click InstallScript. Find the dialog code in the OnFirstUIBefore event for the dialog that should contain the User Name control and add a call to the Windows Installer API function MsiSetProperty. For example, if you want end users to enter the IP address in the edit box in the SdShowDlgEdit1 dialog added to your project, you must add a call to MsiSetProperty, as shown in the following lines of code: Dlg_SdShowDlgEdit1:
nResult = SdShowDlgEdit1 (szTitle, szMsg, szField1, svEdit1);
MsiSetProperty (ISMSI_HANDLE, "MYPROPERTY", svEdit1);
if (nResult = BACK) goto Dlg_SdWelcome;
Create your issue.
a source to share