Search code examples
wixminicondawix3.11

How to prevent duplicate installation of Miniconda when used in a Wix bundle?


I am working on a .NET application (and its installer) that calls python scripts. In order to do that, not just a the application but also Miniconda needs to be installed. However, when there is an update of the application, Miniconda should not be installed again when it is already available.

I tried to achieve that but I do not succeed. Here is my Bundle.wxs (I am using Wix 3.11).

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

    <?include ..\InstallPlugin\Forwards.wxi?>

    <Bundle
        Name="$(var.ProductTitle)"
        Version="$(var.ProductVersion)"
        Manufacturer="$(var.ProductCompany)"
        Copyright="$(var.ProductCopyright)"
        DisableModify="yes"
        DisableRemove="yes"
        IconSourceFile="../Images/Icon.ico"
        UpgradeCode="f8b6f347-2832-41c9-9d89-112144f62ed8"
        >

        <BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.HyperlinkSidebarLicense">
            <Payload SourceFile="..\Deployment\Bootstrapper\bin\Release\net462\Bootstrapper.dll"/>
            <Payload Name="BootstrapperCore.config" SourceFile="..\Deployment\Bootstrapper\Bootstrapper.BootstrapperCore.config"/>
            <Payload Name="en-US\License.rtf" SourceFile="../Licenses/License.en-US.rtf"/>
            <Payload SourceFile="../Images/Logo.png"/>
            <bal:WixStandardBootstrapperApplication
                LicenseUrl="https://SOMETHING"
                ShowVersion="yes" />
        </BootstrapperApplicationRef>

        
        <Chain>
            <PackageGroupRef Id="PluginSystem" />
            <MsiPackage SourceFile="..\InstallPlugin\bin\Release\en-US\InstallPlugin.msi"
                        Compressed="yes"
                        DisplayInternalUI="no"
                        Vital="yes"
                        Visible="yes"
            >
                <!-- <MsiProperty Name="USERLANGUAGE" Value="[UserLanguage]"/> -->
                <MsiProperty Name="USERLANGUAGE" Value="en-US"/>
            </MsiPackage>
            <ExePackage Id="MiniConda"
                        SourceFile="C:\\AnaCondaDependencies\\Miniconda3-py39_4.10.3-Windows-x86_64.exe"
                        DetectCondition="CondaFileFound"
                >
                <ExitCode Value ="3010" Behavior="success" />
            </ExePackage>
        </Chain>
    </Bundle>

    <Fragment>
    <util:RegistrySearchRef Id="CondaFound" />
    <util:FileSearchRef Id="CondaFileFound" />
      <util:RegistrySearch
       Id="CondaFound"
       Root="HKLM" Key="SOFTWARE\Python\ContinuumAnalytics\SupportUrl" Value="https://github.com/continuumio/anaconda-issues"
       Result="exists" Variable="CondaFound" />
    
     <util:FileSearch
       Id="CondaFileFound"
       Path="[CommonAppDataFolder]Miniconda3\python39.dll"
       Variable="CondaFileFound"
       Result="exists" />
    </Fragment>
</Wix>


As becomes clear from the .wxs file shown above, I defined two conditions: CondaFileFound and CondaFound to be used as a DetectCondition. Both are not working for me. The installer just starts the Miniconda installer even when Miniconda is already installed and my condition checks for this. This is really frustrating. What am I doing wrong? And how can I fix this?


Solution

  • as Bob already mentioned you are 'ref'ing your RegistrySeach and FileSearch function calls in the very same Fragment as they are defined. This does not execute them from your Bundle.

    You have to move your RegistrySearchRef and FileSearchRef up into the Bundle definition.

    See the test bundle below.

    <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
      <Bundle Name="Bootstrapper1" Version="1.0.0.0" Manufacturer="cccc" UpgradeCode="b8a7411a-68dc-40a9-9557-d7f64c2e7940">
        <BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense" />
        <util:FileSearchRef Id="searchCmd"/>
        <Chain>
          <ExePackage SourceFile="c:\temp\cmd.exe"  DetectCondition="detected"/>
        </Chain>
      </Bundle>
      <Fragment>
        <util:FileSearch
               Id="searchCmd"
               Path="[WindowsVolume]temp\cmd.exe"
               Variable="detected"
                />
      </Fragment>
    </Wix>