Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WiX Property ID Or Conditional Statement

Tags:

wix

I need to create an install file that will check the registry for the version of another software. Currently I'm commenting and un-commenting lines of code for separate installs. How can I turn the below into an conditional?

<!--<Property Id="ACADREG" Value="ACAD-A001:409" /> Autocad 2012--> 
<Property Id="ACADREG" Value="ACAD-A004:409" /> <!--Autocad Arch 2012--> 

I also need to obtain which version that is for later in the install.

    <Property Id="ACADROAMDIR">
    <RegistrySearch Id="ROAMROOTDIR" Root="HKCU" Type="raw" Key="Software\Autodesk\AutoCAD\[ACADVER]\[ACADREG]" Name="RoamableRootFolder" />
    </Property>


    <Property Id="ACADDIR">
    <RegistrySearch Id="AcadLocRegistry" Type="raw" Root="HKLM" Key="SOFTWARE\Autodesk\AutoCAD\[ACADVER]\[ACADREG]" Name="AcadLocation" />
    </Property>

Is there a way wiX can set [ACADREG] by reading the registry instead of me setting it like I did above?

like image 336
Robert Avatar asked Nov 13 '22 11:11

Robert


1 Answers

You can use a Preprocessor condition:

<?define AutocadSku = "ACAD2012" ?>

<?if $(var.AutocadSku) = "ACAD2012" ?>
  <Property Id="ACADREG" Value="ACAD-A001:409" />
<?else?>
  <Property Id="ACADREG" Value="ACAD-A004:409" />
<?endif ?>

Or even better, the best practice is searching for both, so later on you could conditionally check for each property's existence or content:

<Property Id="ACADROAMROOTDIR">
  <RegistrySearch Id="ROAMROOTDIR" Root="HKCU" Type="raw" Key="Software\Autodesk\AutoCAD\R18.2\ACAD-A001:409" Name="RoamableRootFolder" />
</Property>
<Property Id="ACADROAMARCHROOTDIR">
  <RegistrySearch Id="ARCHROAMROOTDIR" Root="HKCU" Type="raw" Key="Software\Autodesk\AutoCAD\R18.2\ACAD-A004:409" Name="RoamableRootFolder" />
</Property>
like image 100
KMoraz Avatar answered Dec 11 '22 13:12

KMoraz