I'm using instance transforms to install the same product multiple times on the same machine. When starting the .msi installation file, I pass TRANSFORMS=":X" (and several other variables needed for the installation) on the command line, where X is the version of the Program to use.
In the Product.wxs file I then assign a new ProductCode using the InstanceTransforms tag, e.g.:
<Property Id="INSTANCEID" Value="Default"/>
<InstanceTransforms Property="INSTANCEID">
<Instance Id="I1" ProductCode="$(guid.NewGuid())"/>
<Instance Id="I2" ProductCode="$(guid.NewGuid())"/>
<Instance Id="I4" ProductCode="$(guid.NewGuid())"/>
<Instance Id="I3" ProductCode="$(guid.NewGuid())"/>
<Instance Id="I5" ProductCode="$(guid.NewGuid())"/>
<Instance Id="I6" ProductCode="$(guid.NewGuid())"/>
<Instance Id="I7" ProductCode="$(guid.NewGuid())"/>
<Instance Id="I8" ProductCode="$(guid.NewGuid())"/>
<Instance Id="I9" ProductCode="$(guid.NewGuid())"/>
</InstanceTransforms>
Additionally, the UpgradeCode is added to the UpgradeTable in a custom action, the relevant code is:
Database db = session.Database;
session.Log("Get DB: {0}", db.FilePath ?? string.Empty);
string sqlInsertSring = db.Tables["Upgrade"].SqlInsertString + " TEMPORARY";
session.Log("DB Tables, querying with SQL: {0}", sqlInsertSring);
View view = db.OpenView(sqlInsertSring);
session.Log("OpenView, adding two new records to the UpgradeView.");
session.Log("Inserting line: {0}, null, {1}, null, 512, null, \"UPDATE\"",
session["UpgradeCode"], session["ProductVersion"]);
view.Execute(new Record(new object[] { session["UpgradeCode"], null,
session["ProductVersion"], null, 512, null, "UPDATE"}));
session.Log("Inserting line: {0}, {1}, null, null, null, 0, \"NEWERVERSIONINSTALLED\"",
session["UpgradeCode"], session["ProductVersion"]);
view.Execute(new Record(new object[] { session["UpgradeCode"],
session["ProductVersion"], null, null, 0, null, "NEWERVERSIONINSTALLED" }));
view.Close();
Ok, so far so good, this works for installations, allowing me to successfully install two instances of the same program. However, Updates don't seem to work. I can upgrade one of the instances, but when upgrading the second instance the transformation doesn't work correctly and the other instance is upgraded again.
Example: Two instances (I1 & I2). Upgrading I2 works fine. However, when I subsequently try to update I1, it just Updates I2 again (although the correct Transformation is passed).
The log of the MSI shows that the Transformation is first reverted to I1 (as it should), and then set back again to I2 (for reasons I can't fathom):
- MSI (s) (B0:F8) [09:06:48:745]: Running product '{C33371A0-C32A-4120-BD8F-ACDC79E13458}' with elevated privileges: Product is assigned.
- MSI (s) (B0:F8) [09:06:48:776]: PROPERTY CHANGE: Modifying TRANSFORMS property. Its current value is ':I2'. Its new value: ':I1'.
- MSI (s) (B0:F8) [09:06:48:823]: PROPERTY CHANGE: Adding DATADIR property. Its value is
MSI (s) (B0:F8) [09:06:49:463]: PROPERTY CHANGE: Adding CURRENTDIRECTORY property. Its value is 'C:\Users\Administrator\Desktop'.
- [Further arguments passed]
- MSI (s) (B0:F8) [09:06:49:494]: PROPERTY CHANGE: Adding CLIENTUILEVEL property. Its value is '2'.
- MSI (s) (B0:F8) [09:06:49:572]: PROPERTY CHANGE: Adding CLIENTPROCESSID property. Its value is '6424'.
- MSI (s) (B0:F8) [09:06:49:587]: Machine policy value 'DisableAutomaticApplicationShutdown' is 0
- MSI (s) (B0:F8) [09:06:49:634]: RESTART MANAGER: Disabled by MSIRESTARTMANAGERCONTROL property; Windows Installer will use the built-in FilesInUse functionality.
- MSI (s) (B0:F8) [09:06:49:681]: PROPERTY CHANGE: Adding MsiSystemRebootPending property. Its value is '1'.
- MSI (s) (B0:F8) [09:06:49:728]: PROPERTY CHANGE: Modifying TRANSFORMS property. Its current value is ':I1'. Its new value: ':I2'.
- MSI (s) (B0:F8) [09:06:49:821]: TRANSFORMS property is now: :I2
The last lines are significant: The TRANSFORMS property is set to I2 again, meaning that the installation will Update instance I2 instead of Instance I1.
Why could this be happening? The TRANSFORMS is passed correctly, I can't see why the property would be set back again.
(If more code or explenations are needed I'm happy to provide).
EDIT: BTW I'm using WiX toolset 3.7.
EDIT 2: For installation, I'm calling the .msi with following parameters:
MSINEWINSTANCE=1 TRANSFORMS=":I[N]" [Further parameters] (where N is the Instance)
For updates, I'm calling the .msi without MSINEWINSTANCE, starting directly with the TRANSFORMS part
As a dirty fix I'm now Uninstalling/Installing on update, which isn't exactly what I had planned.