Search code examples
wixwindows-installerburn

Conditional uninstall package with Burn


I created an application and packaged it using WiX. But this application requires a prerequisite, like SQL CE 3.5. Then I created a boostrapper using Burn. The requirement is that it will only install SQL CE if it is not previously installed in user's computer.

The problem I'm encountering is that even if it doesn't install (because it is already installed), it uninstall the SQL CE if I uninstall my application. How can I solve this?

Here is the code:

<util:RegistrySearch Root="HKLM" Key="SOFTWARE\Classes\Installer\Products\PACKED_GUID" Value="Version" Variable="SQLCE_Installed" Result="exists" />

<Chain>
  <MsiPackage Id="PkgA" SourceFile="PkgA.msi" DisplayInternalUI="yes" Visible="yes" InstallCondition="SQLCE_Installed" />

EDIT:

The bootstrapper should remove the prerequisite SQL CE only if it was installed by itself. This way (pseudo-code):

function install() {
  if isPrereqInstalled = false {
     call installPreReq()
     boolean bootstrapperInstalledApp = true
  }
}
function uninstall() {
  if bootstrapperInstalledApp = true {
     call uninstallPreReq()
     call uninstallMyApp()
  } else {
     call uninstallMyApp()
  }
}

Solution

  • set Permanent on the Package to "yes"

    <MsiPackage SourceFile="Enclosing1_1.msi" Id="Enclosing" Permanent="yes" Vital="no" Visible="yes">