wix installer 3.7 bootstrapper Registry search
Asked Answered
I

3

7
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
     xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"
     xmlns:bal="http://schemas.microsoft.com/wix/BalExtension"
     xmlns:netfx='http://schemas.microsoft.com/wix/NetFxExtension'>

    <Bundle Name="IPDev" Version="0.6" Manufacturer="MYAPP Corporation" UpgradeCode="f380ae43-5df1-4cfe-9297-526e3e638e57">
        <BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense" />
        <Chain>
            <!-- TODO: Define the list of chained packages. -->
            <PackageGroupRef Id="Netfx45FullPackage"/>      
        </Chain>
    </Bundle>
  <Fragment>
    <!--checking for matlab 2012a installation-->
     <util:RegistrySearch Id="MatlabPath"
            Variable="UniqueId"
            Root="HKLM"
            Key="SOFTWARE\MathWorks\MATLAB\4.17\"
            Result="exists"
            Win64="yes" 
           />
    <!--checking for matlab MCR 2012a 64 bit installation-->
    <util:RegistrySearch Id="MatlabMCRPath"
            Variable="UniqueId"
            Root="HKLM"
            Key="SOFTWARE\MathWorks\MATLAB Compiler Runtime\7.17\"
            Result="exists"
            Win64="yes" 
            />
    <PackageGroup Id="Netfx45FullPackage">

     <ExePackage Id="Netfx45Xxx" Cache="no" Compressed="no" PerMachine="yes" Permanent="yes" Vital="no" InstallCommand="/q"
        SourceFile="..\SetupProject\dotnetfx45_full_x86_x64.exe"
        DetectCondition="(Netfx4FullVersion=&quot;4.5.50709&quot;) AND (NOT VersionNT64 OR (Netfx4x64FullVersion=&quot;4.5.50709&quot;))"
        InstallCondition="(VersionNT >= v6.0 OR VersionNT64 >= v6.0) AND (NOT (Netfx4FullVersion=&quot;4.5.50709&quot; OR Netfx4x64FullVersion=&quot;4.5.50709&quot;))"/>
     <ExePackage Id="MatlabMCR2012a64" Cache="no" Compressed="no" PerMachine="yes" Permanent="yes" Vital="no" InstallCommand="/q"
        SourceFile="..\SetupProject\MCR_R2012a_win64_installer.exe"
        InstallCondition="(NOT MatlabPath) OR (NOT MatlabMCRPath)"/>
    <MsiPackage  Id="IPDev" Cache="no" Compressed="no"  DisplayInternalUI="yes" Vital="yes" SourceFile="..\SetupProject\bin\Release\IPDevSetup.msi"/>   

    </PackageGroup>
  </Fragment>
</Wix>

here's my code: my problem is that .NET4.5 is installed only if it exists.
however MATLAB's MCR is installed whether it exists or not.
can you please tell me what's wrong with my condition:

 InstallCondition="(NOT MatlabPath) AND (NOT MatlabMCRPath)"

fix after Rob's answer:

DetectCondition="MatlabMCRPathExists OR MatlabPathExists"

this condition should be false in order to install

Introvert answered 5/3, 2013 at 8:34 Comment(0)
I
4

The InstallCondition attribute is used to determine whether a package should be installed on the machine. If true, the package is allowed to install. If false, the package is uninstalled. What you want is a DetectCondition attribute to determine whether the package is already present on the machine.

The fix is probably just to change the Matlab ExePackage/@InstallCondition to a ExePackage/@DetectCondition.

Innominate answered 5/3, 2013 at 22:0 Comment(3)
thanks .i have changed into DetectCondition but it skips the installation of MatLab MCR. i had uninstalled MCR and restarted my Computer. this is the log file: "Condition '(NOT MatlabPath) AND (NOT MatlabMCRPath)' evaluates to true." and also "Detected package: MatlabMCR2012a64, state: Present, cached: None" this means that the registry is still there? or do i have a bug in my code?Introvert
i have changed my Condition into an OR and this is what i get Condition 'MatlabMCRPathExists OR MatlabPathExists' evaluates to false. however MCR is installedIntrovert
The log file should show you the state of all the variables being set so you can see what Burn thinks the searches are finding. Take a look at your machine and verify that the registry keys are the way you expect they are. The DetectCondition will do what you want, once you can correctly detect Matlab.Innominate
I
5

Here is my final and working code:
this code check's for .NET 4.5 installation. and for Matlab R2012a or Matlab MCR R2012a.

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
     xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"
     xmlns:bal="http://schemas.microsoft.com/wix/BalExtension"
     xmlns:netfx='http://schemas.microsoft.com/wix/NetFxExtension'>

    <Bundle Name="IPDev" Version="0.6" Manufacturer="Intel Corporation" UpgradeCode="f380ae43-5df1-4cfe-9297-526e3e638e57">

        <BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense" />
        <Chain>

            <!-- TODO: Define the list of chained packages. -->
            <PackageGroupRef Id="Netfx45FullPackage"/>      
        </Chain>
    </Bundle>
  <Fragment>

      <!--checking for matlab 2012a installation-->
    <util:RegistrySearch Id="MatlabPath"
           Variable="MatlabPathExists"
           Root="HKLM"
           Key="SOFTWARE\MathWorks\MATLAB\4.17"
           Result="exists"
           Win64="yes" />
    <!--checking for matlab MCR 2012a 64 bit installation-->
    <util:RegistrySearch Id="MatlabMCRPath"
            Variable="MatlabMCRPathExists"
            Root="HKLM"
            Key="SOFTWARE\MathWorks\MATLAB Compiler Runtime\7.17"
            Result="exists"
            Win64="yes"  />
    <PackageGroup Id="Netfx45FullPackage">


     <ExePackage Id="Netfx45Xxx" Cache="no" Compressed="no" PerMachine="yes" Permanent="yes" Vital="no" InstallCommand="/q"
        SourceFile="..\SetupProject\dotnetfx45_full_x86_x64.exe"
        DetectCondition="(Netfx4FullVersion=&quot;4.5.50709&quot;) AND (NOT VersionNT64 OR (Netfx4x64FullVersion=&quot;4.5.50709&quot;))"
        InstallCondition="(VersionNT >= v6.0 OR VersionNT64 >= v6.0) AND (NOT (Netfx4FullVersion=&quot;4.5.50709&quot; OR Netfx4x64FullVersion=&quot;4.5.50709&quot;))"/>
     <ExePackage Id="MatlabMCR2012a64" Cache="no" Compressed="no" PerMachine="yes" Permanent="yes" Vital="no" InstallCommand="/q"
        SourceFile="..\SetupProject\MCR_R2012a_win64_installer.exe"
        DetectCondition="MatlabMCRPathExists OR MatlabPathExists"/>
    <MsiPackage  Id="IPDev" Cache="no" Compressed="no"  DisplayInternalUI="yes" Vital="yes" SourceFile="..\SetupProject\bin\Release\IPDevSetup.msi"/>   

    </PackageGroup>
  </Fragment>
</Wix>
Introvert answered 5/3, 2013 at 23:31 Comment(0)
I
4

The InstallCondition attribute is used to determine whether a package should be installed on the machine. If true, the package is allowed to install. If false, the package is uninstalled. What you want is a DetectCondition attribute to determine whether the package is already present on the machine.

The fix is probably just to change the Matlab ExePackage/@InstallCondition to a ExePackage/@DetectCondition.

Innominate answered 5/3, 2013 at 22:0 Comment(3)
thanks .i have changed into DetectCondition but it skips the installation of MatLab MCR. i had uninstalled MCR and restarted my Computer. this is the log file: "Condition '(NOT MatlabPath) AND (NOT MatlabMCRPath)' evaluates to true." and also "Detected package: MatlabMCR2012a64, state: Present, cached: None" this means that the registry is still there? or do i have a bug in my code?Introvert
i have changed my Condition into an OR and this is what i get Condition 'MatlabMCRPathExists OR MatlabPathExists' evaluates to false. however MCR is installedIntrovert
The log file should show you the state of all the variables being set so you can see what Burn thinks the searches are finding. Take a look at your machine and verify that the registry keys are the way you expect they are. The DetectCondition will do what you want, once you can correctly detect Matlab.Innominate
O
3

You can correct your RegistrySearch call like below:

<!--checking for matlab 2012a installation-->
 <util:RegistrySearch Id="MatlabPath"
        Variable="MatlabPathExists"
        Root="HKLM"
        Key="SOFTWARE\MathWorks\MATLAB\4.17\"
        Result="exists"/>
<!--checking for matlab MCR 2012a 64 bit installation-->
<util:RegistrySearch Id="MatlabMCRPath"
        Variable="MatlabMCRPathExists"
        Root="HKLM"
        Key="SOFTWARE\MathWworks\MATLAB Compiler Runtime\7.17\"
        Result="exists"/>
<PackageGroup Id="Netfx45FullPackage">

This search sets the search result to the variable MatlabPathExists and MatlabMCRPathExists.
Then your condition check should be like following using those variables:

DetectCondition="(NOT MatlabPathExists) OR (NOT MatlabMCRPathExists)"
Obelia answered 5/3, 2013 at 9:58 Comment(6)
thanks, my Goal is to install Matlab MCR only if there is no MATLAB or MCR installed. doesn't your InstallCondition means to install MCR if one of them is not found?Introvert
@Androidy, then the condition check logic needs some correction. I just used the correct variable in util:RegistrySearch and used the same properly. Then your condition check can be like InstallCondition="(NOT MatlabPathExists) AND (NOT MatlabMCRPathExists)" I hope.Obelia
your condition is using OR. I hope it will work with AND. I changed that so.Obelia
I think I am getting confused about the condition you need. I hope if MATLAB or MCR is installed, then you don't need to install anything. Otherwise you need to install Matlab MCR. If I am wrong about my understanding please correct me. By not working what is did you mean exactly? Is it throwing any error on running this or just that condition is not working as expected but installing?Obelia
the condition means: if Matlab or MCR si installed don't install anything. otherwise install MCR. not working means that you run the compiler while MCR is installed and it's trying to install MCR againIntrovert
may i should use util:filesearch however i don't know which file to search for.Introvert

© 2022 - 2024 — McMap. All rights reserved.