Brannon
Brannon

Reputation: 5414

modify wix-made bundle binary

Here's my situation. I have a WiX bundle package with a custom installer UI. It has one MSI packaged into it (that has no UI). You can download that bundle from my server. I want to modify that bundle just before it's downloaded to pass the current address of the server into the MSI. (The MSI is setup to take the server address as a parameter and write that to the app.config.)

I'm aware that this can be done directly on the MSI using the Microsoft.Deployment.WindowsInstaller library (although I'm not sure that I could even do that on a signed MSI and bundle).

Which one of these options is the best way to accomplish this?

  1. Do a binary replace in the bundle. (I tried to find the server parameter in the bundle binary. I can't see anything of the kind.)

  2. Repackage the bundle EXE into a new .NET EXE using CodeDom. The new EXE contains the original bundle as an embedded resource, extracts to a temp file, runs it. This is my current approach, but it's painful to get all the attributes right and get the resource in and out in one piece. I haven't yet succeeded.

  3. Use WiX to extract the bundle, modify the source, and then rebuild it. I'm not sure how this plays with a signed bundle. It would also require me to install WiX along side my server. Is there some PackageRef I can use in a bundle to install WiX itself?

  4. Find the CAB file header. Extract it. Modify the MSI. Repalce the CAB bytes in the bundle. I tried this approach. It gives me this error: Failed to verify hash of payload. I can't see where the hash is encoded in the bundle.

  5. Use some other binary manipulation or API of which I'm not aware? I can use any version of WiX.

Upvotes: 2

Views: 427

Answers (2)

Brannon
Brannon

Reputation: 5414

I could get none of the other options here to work. I actually ended up repackaging my EXE with iexpress.exe (which I had no idea existed until dealing with this issue). I repackaged it and made the package call the original with a command line that overrides the server address. The repackaging is done as a custom step with the server installer.

Upvotes: 0

l33t
l33t

Reputation: 19937

Use a VBScript or similar script language to patch the MSI. Like the answer here. However, you need to re-sign the package after patching it. Otherwise you end up with an MSI with an invalid signature.

Or add a custom action to your MSI that asks your server what URL it should use.

Update

After some thought I think I would compile the bundle on the server. Just generate the Bundle.wxs programmatically, with a property set to the url in question - then compile it using the same command-line as usual (should be available in the build log if you're using Visual Studio). In you Chain, add this:

<MsiPackage Id="MySoftware" SourceFile="$(var.Setup.TargetPath)" Vital="yes">
  <MsiProperty Name="MyUrl" Value="URL_WRITTEN_BY_SERVER"  />
</MsiPackage>

More about the MsiPackage element here.

Upvotes: 1

Related Questions