Tuesday, November 3, 2015

Wix Bundle Conditions with Third-party installer and registry search.

This issue might be easy for many developers, but like me who sometimes get confused with logical expressions, so I'm simply documenting here.

Scenario:
Bundle.exe have to search Registry key to check if a third-party  (MATLab Runtime 8.2) is installed.
 If (not installed), 
   the install it with provided third-party installer, 
else
   got with normal installation.

If (not installed and third-party installer is missing)
inform user about missing required runtime and quit.

While dealing with missing installer file, and building the logical expression for Condition, I face some confusion. However, solved it and here is the working parts:

    <util:RegistrySearchRef Id="MATLabCompilerRuntimeReg"/>
    <util:FileSearchRef Id="MATLabRuntimeInstaller" />      
    <bal:Condition Message="$(var.ProductName) requires the installation of MATLAB Compiler Runtime 8.2. Please install MATLAB Compiler Runtime 8.2 before installing this product. " >
      <![CDATA[Installed OR MATLabRuntimeInstallerExist OR (MATLabCompilerRuntimeVersion="8.2")]]> 
    </bal:Condition>


<Fragment Id="PreReqs">
    
    
    <util:RegistrySearch Id="MATLabCompilerRuntimeReg" 
        Variable="MATLabCompilerRuntimeVersion"                      
        Root="HKLM"
        Key="SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\MATLAB Compiler Runtime R2013b"        
        Value="DisplayVersion" 
        Result="value" 
        Win64="yes" 
    />
    <util:FileSearch 
      Id="MATLabRuntimeInstaller"
      Path="[WixBundleOriginalSourceFolder]MCR_R2013b_win64_installer.exe"
      Result="exists" 
      Variable="MATLabRuntimeInstallerExist" 
    />
    
    <PackageGroup Id="PreReq">
      <ExePackage Id="MATLabRuntime2013b"
        DisplayName="MathWorks MATLAB Compiler Runtime 8.2"
        Description="MathWorks MATLab Compiler Runtime 8.2"
        Cache="no"
        Compressed="no"
        PerMachine="yes"
        Permanent="yes"
        Vital="yes"
        SourceFile="D:\Pre-Reqs\MATLab\MCR_R2013b_win64_installer.exe" 
        Name="MCR_R2013b_win64_installer.exe"                  
        Protocol="none"  
        DetectCondition="MATLabCompilerRuntimeVersion="8.2""
        InstallCondition="(NOT (MATLabCompilerRuntimeVersion="8.2"))"
         
      />    
    </PackageGroup>
    
  </Fragment>

No comments: