tags:

views:

3507

answers:

4

After way too many experiments, I've come to the conclusion that Windows Installer is simply bad technology.

But customers want MSI files.

So, how can I create a MSI that extracts an EXE to a temp directory and runs it with options same or similar as were passed to the exe?

Options to an MSI are explained here (low level "run" of an MSI is msiexec option package.msi): http://technet.microsoft.com/en-us/library/cc759262.aspx.

EDIT: mjmarsh's WiX solution looks like it works. I just haven't had a chance to try it yet (crunch time). If it works, I'll be accepting it.

EDIT: does not work. Missing piece: attended/unattended does not seem to be available.

Anyway, the only to make this work at all would be for the custom action to kill its parent process!

+4  A: 

I think the easiest way to create a .MSI is to use wix.

Lesson 1 from the Wix tutorial is all you need to create a simple install.

GvS
+3  A: 

Well there is the free way and the $$$ way. I cannot document everything here but this should get you started.

On a side note, yes, Windows Installer is a maddening technology. There are many times where I think a task will be straight forward but actually becomes complicated. You definitely have to immerse yourself to understand it.

In any case, here goes:

Free: WIX (here)

This is a free tool to generate MSI files from a set of XML configuration files. I'll leave you to find tutorials online, but here is the crux:

You can compress your EXE into the installer by using the following tag in the WXS file:

<Binary Id="MYEXE" src="<path to my exe?"/>

Then you can create a custom action which launches your EXE

<CustomAction Id="EXECA_CALLMYEXE" Return="check" Execute="deferred" BinaryKey="MYEXE"
      ExeCommand="my command line"/>

Then you insert your custom action into the InstallExecuteSequence in the appropriate spot (I almost always run mine somewhere between InstallInitialize and InstallFinalize)

<InstallExecuteSequence>
   <Custom Action="EXECA_CALLMYEXE" After="InstallInitialize"><![CDATA[Not REMOVE]]></Custom>

$$$: Get Installshield (HERE

First create a "Basic MSI" project and make sure you say you want no setup.exe generated. You set this in the Release settings.

Then you essentially do the same thing as with WIX but you have a UI for it.

  • You can specify your helper EXE by using the Direct Editor and putting your EXE in the 'Binary' table
  • You can create a custom action to launch that EXE from the "Custom Actions" Node in the tree on the left
  • You can insert the custom action by selecting "Install Sequences" and putting it in the InstallExecuteSequence somewhere between InstallInitialize and InstallFinalize as I said before.

Sorry I could not be more detailed, but this should be a good start.

mjmarsh
The installshield way is already known not to work. It does not extract to a temp directory but to the target directory, running into the same bug we are trying to avoid in the first place (modify date on target file is often flat out wrong).
Joshua
Looks like WiX can do it w/ Custom Action and Binary element. Unfortunately the tutorial is currently busted but the help file in the download binary works.
Joshua
Huh, I was unaware of the binary extraction issue with IS. What version do you use?
mjmarsh
+2  A: 

Joshua, I understand your frustration very well. MSI is quirky to say the least - a completely new way to think of deployment. Still, applied correctly MSI offers the best possible deployment, especially for corporate customers.

What operations does your installer EXE perform? Is it largely file copy, some COM registration and some registry writes, or does it run complex installation logic, setting up databases etc...? The reason I ask is because it probably would be very quick to create a well functioning WIX MSI for you so you can abandon the EXE approach.

It is indeed possible to run an EXE from inside an MSI, but it requires proper sequencing, and it is guaranteed to cause you more blues than a simple MSI. If the app is small, and not doing anything crazy during installation, I would be happy to provide you with a basic WIX conversion.

Glytzhkof
MSI known bug: will not update executable binary that was touched by something else.
Joshua

related questions