How to use CustomAction in WIX Bundle?
Asked Answered
H

2

15

To give you a background - I have a 4 MSI's which comes from our vendor and this has to go to our company servers (we are looking at around 3500 servers). As of now, my counterparts are managing this using vbs, ps1 scripts. But the problem with the script is that everytime an update comes we have to worry about uninstalling the existing package before running the new one and a ton of hardcoding.

I want to automate the whole process (with very less hardcoding) by setting up a WIX script to package all the 4 MSI's together. I read about the WIX bundle and used that to create a single MSI. But now there are lot of a variables to be passed to the 4 MSI's, so I thought of using custom actions to set these variables based on the environment/machine where the MSI is running. But I cant make custom action to work? Am i missing something?

A little bit of googling and I saw something like there are no CustomActions in Bundle? can someone confirm?

Also if there are no CA's what are my options? how can I manipulate the variables to be passed on to the 4 MSI's? Most of them needs to be set based on the machine its being run (like install path, user id's, app pool id's etc).

Hygro answered 22/10, 2012 at 19:36 Comment(0)
H
4

As I see it, you have three options:

  1. Depending on what information you need, you can use the WixUtilExtension to perform simple tasks such as reading registry keys and performing file searches, which you can then pass the results to your installation packages as properties.

  2. Implement custom actions in the individual installation packages themselves (not in the bundle).

  3. Write your own custom bootstrapper application to determine all the properties you need to set, and then pass them to your installation packages. This is more complex than the #1 and #2, but if your interested the following links should get you started: introducing managed bootstrapper applications and write a wpf wix installer

Hexarchy answered 23/10, 2012 at 15:55 Comment(3)
Makes sense! I tried everything possible to get the CA's running in the bundle and it just doesnt get called. From what I understand, even though the WIX Bundle generates an MSI file, it's not actually an MSI (you cant run it with msiexec or open it with ORCA). It's just an exe or a program which combines all the MSI's together and it doesnt have any of the properties of an MSI. P.S:I think just to make it confusing MS named it as an MSI :)Hygro
@user1766402, I hadn't even realized it was possible to output the bundle as an msi until I read your question. You can right click the project in visual studio and select Properties, and change the output to .exe. That should be what the default is for bundle/bootstrapper projects anyway.Hexarchy
A WiX Bundle is not an MSI, it's an executable. Renaming the .exe to .msi isn't going to change that. :)Une
M
15

There is a fourth option, a useful lightweight hack, identified by Vijay Kotecha (see http://vijayskotecha.blogspot.com/2013/07/wix-bootstrapper-custom-action.html),...

Essentially, build an <ExePackage> around a pass-through .bat or .cmd batch file. The batch/command file contains the single line '%*' which re-executes all of the command line arguments as a first class command.

Thus:

<ExePackage ... SourceFile="SourcePath\WixCustomAction.cmd"
    InstallCommand="my_custom_action.exe my_custom_parameters" />
<ExePackage ... SourceFile="SourcePath\WixCustomAction.cmd"
    InstallCommand="my_next_action.exe my_next_parameters" />

Where WixCustomAction.cmd is a file containing only '%*'.

These <ExePackages> can be placed into the <Bundle><Chain> successively as needed using different InstallCommands as needed.

Mustachio answered 5/12, 2015 at 22:28 Comment(1)
This may work during the installation phase, when ExePackage installation event would be triggered. But can't be used at the start of installation, such as some prerequisite checks and display some error message ...Crotchet
H
4

As I see it, you have three options:

  1. Depending on what information you need, you can use the WixUtilExtension to perform simple tasks such as reading registry keys and performing file searches, which you can then pass the results to your installation packages as properties.

  2. Implement custom actions in the individual installation packages themselves (not in the bundle).

  3. Write your own custom bootstrapper application to determine all the properties you need to set, and then pass them to your installation packages. This is more complex than the #1 and #2, but if your interested the following links should get you started: introducing managed bootstrapper applications and write a wpf wix installer

Hexarchy answered 23/10, 2012 at 15:55 Comment(3)
Makes sense! I tried everything possible to get the CA's running in the bundle and it just doesnt get called. From what I understand, even though the WIX Bundle generates an MSI file, it's not actually an MSI (you cant run it with msiexec or open it with ORCA). It's just an exe or a program which combines all the MSI's together and it doesnt have any of the properties of an MSI. P.S:I think just to make it confusing MS named it as an MSI :)Hygro
@user1766402, I hadn't even realized it was possible to output the bundle as an msi until I read your question. You can right click the project in visual studio and select Properties, and change the output to .exe. That should be what the default is for bundle/bootstrapper projects anyway.Hexarchy
A WiX Bundle is not an MSI, it's an executable. Renaming the .exe to .msi isn't going to change that. :)Une

© 2022 - 2024 — McMap. All rights reserved.