Simulating an OR Condition in the Bootstrapper Package
The installation bootstrapper created by the GenerateBootstrapper task in Visual Studio does not have support for compound conditions in the product.xml file. There is however a way to simulate an OR condition as I did with a product that required either Excel version 12 or 14 to be installed.
If you read carefully the description of the RegistryFileCheck you will notice that it says, “If this key does not exist, Property is not set.” That subtle, but very important statement started me thinking. If I were to do two or more RegistryFileChecks into the same property, would it indeed leave the results of the first check if the second key were absent? Yes, it does. Below is an example of how to use this information to determine if Excel 12 or 14 is installed.
<InstallChecks>
<RegistryFileCheck Property=”ExcelVersion”
Key=”HKLM\Software\Microsoft\Office\12.0\Excel\InstallRoot”
Value=”Path” FileName=”EXCEL.EXE” SearchDepth=”0″ />
<RegistryFileCheck Property=”ExcelVersion”
Key=”HKLM\Software\Microsoft\Office\14.0\Excel\InstallRoot”
Value=”Path” FileName=”EXCEL.EXE” SearchDepth=”0″ />
</InstallChecks>
The two checks above leave the property ExcelVersion in one of two states. Either it will contain the version of the higher version of Excel that is installed or it will be “NotExists” if both version 12 and 14 are absent
Once you have the “ExcelVersion,” it is easy to use to fail the installation if neither version of Excel is installed. Add the following to the InstallConditions portion of the Commands in the product.xml file.
<FailIf Property=”ExcelVersion”
Compare=”ValueNotExists” String=”Excel2007SP2″/>