Use WiX to make update-able and fresh-installable MSI

Problem

To update a MSI file (small/minor update), you have to specify command line options like this.

msiexec /i foo.msi REINSTALL=ALL REINSTALLMODE=vomus

When it’s too tedious, you can use IExpress to wrap the MSI file into an executable (EXE). When started, the executable extracts the wrapped MSI and run the specified command line above.

The problem is, however, the command line does not work for a new (fresh) installation. You may not use "REINSTALL=ALL" in the case of fresh install.

Let’s solve it with WiX, the XML based MSI authoring tool.

 

Solution

The basic idea is to remove REINSTALL property by MSI custom action in the case of fresh install.

The first step is to define the custom action for this. The custom action (called CA_DISABLE_REINSTALL) sets the empty string to REINSTALL property.

<CustomAction Id=’CA_DISABLE_REINSTALL’ Property=’REINSTALL’ Value=”/>

The second step is to run the custom action if the application has been installed. You want to specify it in two places (InstallExecuteSequence and InstallUISequence).

<InstallExecuteSequence>
  <Custom Action=’CA_DISABLE_REINSTALL’ Sequence=’999′>NOT Installed</Custom>
</InstallExecuteSequence>

<InstallUISequence>
  <Custom Action=’CA_DISABLE_REINSTALL’ Sequence=’999′>NOT Installed</Custom>
</InstallUISequence>

I don’t fully understand the purpose of Sequence=’999′, but it seems to be a right thing.

That’s it. Your MSI now automatically removes the specified REINSTALL property in the case of fresh install.

Advertisements

About Moto

Engineer who likes coding
This entry was posted in Tips. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s