Wednesday, May 5, 2010

Check if related product is already installed

If your application depends on some another basic application, you need to check if the basic application is already installed. You can use the FindRelatedProducts action.
Use the following steps:
1) Define the UpgradeCode of the basic product:
<Upgrade Id="PUT_YOUR_GUID_HERE">
<UpgradeVersion OnlyDetect="yes" Minimum="1.0.0.0" IncludeMinimum='no' Property="BASICINSTALLED" />
</Upgrade>
2) Specify a Custom Action performed if the basic product is not installed:
<CustomAction Id='NotBasic' Error='The basic product should be installed on the server.' />

3) Schedule the custom action execution
<InstallUISequence>
<Custom Action='NotBasic' After='FindRelatedProducts'>NOT BASICINSTALLED</Custom>
</InstallUISequence>

During installation, Windows Installer define a Product Code for the specified Upgrade Code and assign it to the BASICINSTALLED property. If there is no products installed with the Upgarde Code, the property is not defined. In this case the Custom Action will be performed and installation completes.

Note: The property assignment will be skipped if the basic appliaction is installed on per-machine mode but your application is installing in per-user mode.
The following log is written:
FindRelatedProducts: current install is per-user. Related install for product '{Product_Code_GUID}' is per-machine. Skipping...

No comments:

Post a Comment