Using Windows Installer Properties to Dynamically Modify XML Files

InstallShield 2020

Project:This information applies to the following project types:

Basic MSI
DIM
InstallScript MSI
Merge Module
MSI Database
Transform

For Basic MSI, DIM, InstallScript MSI, Merge Module, MSI Database, and Transform projects, you can use a Windows Installer property to specify an XML element, an attribute, an attribute value, or an element’s content. At run time, Windows Installer uses MsiFormatRecord to resolve the property value, and it uses that value as the data in your XML file. This enables you to use data that end users enter in dialogs, or other configuration information that is determined during the installation, in your product’s XML files.

For example, your installation may include the SQL Login dialog, which lets end users select a SQL Server. The name of the server that they select is typically stored in the IS_SQLSERVER_SERVER property. If you want an XML file to contain the name of the SQL server that an end user selects, you can use this property, surrounded by brackets (that is, [IS_SQLSERVER_SERVER]), when you configure your XML file changes in the XML File Changes view. Then at run time, Windows Installer automatically replaces the property with its associated value.

Tip:Use a Windows Installer property for an element, an attribute, or element content only if the value of the property would make a well-formed XML document. If a property value would lead to syntax errors in the XML document, your product or installation may not behave as expected.

For example, if you set the name of an element to [INSTALLDIR]—a Windows Installer property whose value is a path on the target system—the result at run time is an element name that contains backslashes. Element names cannot contain backslashes, and XML documents that contain element names with backslashes are not valid.

Note:If test your XML file from within the XML File Changes view, any Windows Installer properties that are used for XML data are not replaced with the appropriate values during testing. For more information about testing, see Testing Installation Changes to an XML File or Testing Uninstallation Changes to an XML File.

Example

The following procedure demonstrates how to use the name of the SQL Server that an end user selects in the SQL Login dialog as the content for one of the elements in your XML file. Note that you can substitute a hard-coded value with a property for any of the elements, attributes, attribute values, or element content in the XML File Changes view. The property that you specify in this view must be enclosed within square brackets, and the property name must be in all uppercase letters; for example, [MYPROPERTY].

To use the name of the SQL Server that end users select as the content for an XML element:

1. Configure the SQL connection and any associated SQL scripts if you have not already done so, and determine the name of the server property name:
a. In the View List under Server Configuration, click SQL Scripts.
b. Add a SQL connection and SQL scripts as needed. For instructions, see Configuring SQL Support.
c. In the SQL Scripts explorer, click the SQL connection.
d. Click the Advanced tab.
e. Note the name that is selected for the Target Server Property Name setting. The default value is typically IS_SQLSERVER_SERVER.
2. In the View List under System Configuration, click XML File Changes.
3. In the XML Files explorer, select the element to which you want to add content.
4. Select the Advanced tab.
5. Select the Set element content check box.
6. In the Content box, type the name that is selected in step 1e, and enclose it within brackets. For example:

[IS_SQLSERVER_SERVER]

7. Build your release.

See Also