Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install multiple instances of an MSI with dynamic instance name

Our product has an MSI installer (written in WiX) which basically copies some files into a folder c:\ourproduct and installs a windows service "ourwindowsservice".

We'd like to add support for multiple instances of the service, and it should be possible to install/uninstall them independently of each other. Similar e.g. to SQL Server, each instance should have a name which can be passed to the MSI as a command line parameter.

Example: instance "A" => copy files to "c:\ourproductA", install service as "ourwindowsserviceA" instance "B" => copy files to "c:\ourproductB", install service as "ourwindowsserviceB" ...

Any idea?

Instance transformation seems to require a pre-defined and pre-named set of instances.

Thanks

like image 961
Max Avatar asked Jan 06 '11 23:01

Max


2 Answers

The ServiceInstall table's name column is the Formatted Type. These means you can use properties at runtime to drive the name.

A few years back I wrote a blog article on multiple instance installers. In the comments someone asked about a dynamic number of instances and I talk about what would need to be done. Basically you'd have to write a bootstrapper.exe that had a UI and could drive the creation of transforms with unique properties. Using C# and WiX/DTF for your MSI Interop it's actually quite possible. I just never felt the need to actually do it. I've been perfectly happy with Product, Product-1 ... Product-15 and you are done. ShortCuts have to be done by a custom action because they don't support Formatted type but INSTALLDIR can be morphed and ServiceNames do support Formatted.

like image 109
Christopher Painter Avatar answered Oct 29 '22 06:10

Christopher Painter


Unfortunately the article you mentioned is correct, Windows Installer doesn't support dynamic instances. Even commercial tools which support multiple instances require defining the instances from the start. So in your case you would need to define instances A, B, C etc manually before generating the installer.

This is because a product is identified by its ProductCode (among other things), so you need to apply a transform to your MSI which changes the identity. It's pretty hard to generate transforms on the fly because you need special tools or Windows Installer API which is usually not found on an user machine.

However, like Christopher mentioned, you can try simulating a dynamic instance by using installer properties. These properties can be set through the installation UI or by a custom bootstrapper.

like image 44
rmrrm Avatar answered Oct 29 '22 05:10

rmrrm