Wix/Burn - condition to not run MSIPackage and thus not uninstall app

1.1k views Asked by At

I've got myself into a bit of state with a version of my WiX Bootstrapper that is out in the field and am struggling to see how I can get round my problem with the new version.

Basically the version that is out there has a couple of MSIPackage elements that installs SQL CLR & SMO using Mircosoft's standard MSIs (SQLSysClrTypes.msi & SharedManagementObjects.msi) - but unfortunately they are the x64 versions. Now that's fine for 64bit PCs (as our app can use the 64bit version) and so on those PCs all is ok. But obviously when someone tries and installs it on a 32bit machine, it fails.

So, what I'm wanting the new setup.exe to do; is to detect if the 64bit version is installed & it's version (which I do via a Registry search); if it is, then don't do anything (ie don't install the x86 version). Also detect if the x86 version is installed & it's version (again I can do this) - then only install the x86 version; if neither the x86 or the x64 version is installed ( or they are not the correct version - in this case v13.0.1601.5)

My logic for this was:

    <util:RegistrySearch Id="IsSMOInstalledx86"
        Root="HKLM"
        Key="SOFTWARE\Microsoft\Microsoft SQL Server\SharedManagementObjects\CurrentVersion"
        Value="Version"
        Result="value"
        Variable="SMOVersionx86"/>

<util:RegistrySearch Id="IsSMOInstalledx64"
        Root="HKLM"
        Key="SOFTWARE\Microsoft\Microsoft SQL Server\SharedManagementObjects\CurrentVersion"
        Value="Version"
        Win64="yes"
        Result="value"
        Variable="SMOVersionx64"/>

and

      <MsiPackage SourceFile="$(var.DependenciesPath_Microsoft)\System CLR Types for SQL Server 2016\v13.0.1601.5\SQLSysClrTypes.msi"
              Id="SQLCLR"
              DisplayName="System CLR Types for SQL Server 2016"
              Visible="yes"
              InstallCondition="(SMOVersionx86 &lt;&gt; &quot;13.0.1601.5&quot;) AND (SMOVersionx64 &lt;&gt; &quot;13.0.1601.5&quot;)"
              SuppressSignatureVerification="yes"/>

  <MsiPackage SourceFile="$(var.DependenciesPath_Microsoft)\Shared Management Objects\v13.0.1601.5\SharedManagementObjects.msi"
              Id="SQLSMO"
              After="SQLCLR"
              DisplayName="Shared Management Objects for SQL Server 2016"
              Visible="yes"
              InstallCondition="(SMOVersionx86 &lt;&gt; &quot;13.0.1601.5&quot;) AND (SMOVersionx64 &lt;&gt; &quot;13.0.1601.5&quot;)"
              SuppressSignatureVerification="yes"/>

But my problem is that when this is run on a 64bit PC (where SMO is already installed) - the InstallCondition evaluates to FALSE and as the WiX documentation clearly states; if it evaluates to FALSE, then the product is UNINSTALLED - which is obviously not what I want.

There is never a situation that I want the InstallCondition to evaluate to FALSE i.e. I never should uninstall SMO (if for no other reason, than the user may have installed that for a different app to use i.e. not one of ours). I could remove the installCondition and then it would just install the x86 version on both 32bit and 64bit machines - which is fine; but a bit naff.

So, what I want to do in pseudo code, is something like:

If SMOVersionx86 <> "13.0.1601.5" AND SMOVersionx64 <> "13.0.1601.5"
then
    call the MSIPackages (with no installcondition or always TRUE) to INSTALL
else
    don't call the MSIPackages"
Endif

i.e. if the condition results in FALSE; then I don't want to do anything ... certainly don't want to call the MSIPackages with FALSE, as this would UNINSTALL them.

I've racked my brain with all sorts of ideas, but they all in some circumstances end up with the installCondition evaluating to false and so end up removing SMO. I thought that perhaps I could have some logic that does install the x64 version on a 64bit PC and the x86 version on a 32bit PC, but even then at least one of the MSIPackage's installcondition would evaluate to false and end up removing a version !!

Any help on this would be gratefully received !!

Cheers,

Big Chris.

1

There are 1 answers

0
Stephen Jennings On

MsiPackage has a property Permanent that declares whether a package can be uninstalled. Setting it to "yes" will prevent the bundle from attempting to uninstall it.

However, I'm not sure if adding that property to a new bundle will prevent the old bundle from uninstalling it.