WiX - How to use a config file to decide which MSI to run?

527 views Asked by At

I would like to create an installer suite that runs multiple installers in a chain. The main suite should use a configuration file, such that the installer decides which versions of MSI's to run in terms of this config XML. The goal is to avoid having to update any of the WiX or Bootstrapper projects when a new version of software comes out. Instead, one would only have to update the config XML to change what will be installed inside the chain.

For example, one would simply update the source path of a specific MSI inside the XML, so that the main installer would read this new path and run the new MSI instead of the old one.

As far as I understand, the problem in a Bootstrapper project is that all packages are hardcoded, so it doesn't provide flexibility for the source path of the packages.

I also tried using Custom Actions inside individual MSI's. It looked promising that I could get and set properties of the MSI using C# after reading the XML, however these properties could not be used as variables for source paths.

I also tried running a second MSI using Custom Actions inside the first MSI. This sadly did not work out.

I would appreciate any recommendations!

tldr, I'd like to run installers which were not originally included in the build. Similarly to 'DownloadUrl', but from a local network. Its value could be altered using properties, so there'd be no need to rebuild the project every time a path changes.

1

There are 1 answers

4
bradfordrg On

I think this would be difficult using a single XML file to control which packages are installed. Within a burn script, the options for setting variables are limited to:

  • <FileSearch>
  • <RegistrySearch>
  • <DirectorySearch>
  • <ComponentSearch>
  • <ProductSearch>

Of these only <FileSearch> and <DirectorySearch> can probe the source location.

You might be able to get this to work using the presence/absence of a file to control the installation of an MSI package. In your burn project use a util:FileSearch element to find a file from the source path:

<util:FileSearch Id="InstallMSI01"
      Variable="InstallMSI01"
      Result="exists"
      Path="[SourceDir]InstallMSI01.txt" />

This should set the variable InstallMSI01 to "true" or "false" depending on whether the file InstallMSI01.txt exists in the source path. You could then use the variable in an install condition in an MSIPackage:

<MsiPackage
    Id="MSI01"
    SourceFile="-- Your Source Path--"
    InstallCondition="InstallMSI01 = &quot;true&quot;">
</MsiPackage>