Incorrect instance conversion during upgrade

I use instance transformations to install the same product several times on the same computer. When I run the .msi installation file, I pass TRANSFORMS = ": X" (and several other variables necessary for installation) to the command line, where X is the version of the Program used.

In the Product.wxs file, I then assign a new ProductCode using the InstanceTransforms tag, for example:

<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>

In addition, the UpgradeCode is added to the UpgradeTable in a custom action, the corresponding code:

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();

, , , . . , , .

: (I1 I2). I2 . , I1, I2 ( ).

MSI , I1 ( ), I2 ( , ):

 - 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

: TRANSFORMS I2, , I2 I1.

? , , .

( , ).

EDIT: BTW WiX 3.7.

EDIT 2: .msi :

MSINEWINSTANCE=1 TRANSFORMS=":I[N]" [Further parameters] (where N is the Instance)

.msi MSINEWINSTANCE, TRANSFORMS

, / , , .

+4
1

MSINEWINSTANCE, , , . . . .

: ( , 8 ?)

MSI InstallShield 12

Update:

WiX IsWiX.

1: IsWiX MSI/MSM.

2: , . ( , : a) , /, b) , , . , )

3. XML wxs Product.wxs:

<SetProperty Id="INSTALLLOCATION" Value="[ProgramFilesFolder][Manufacturer]\[ProductName]" Before="AppSearch" Sequence="first">Not INSTALLLOCATION and Not Installed</SetProperty>
<Property Id="InstanceId" Value="0"/> 
<InstanceTransforms Property="InstanceId">
  <Instance Id="I1" ProductCode="*" UpgradeCode="{10E90C30-F117-4EE8-A084-25E4D0076CE4}" ProductName="ProductName-1" />
  <Instance Id="I2" ProductCode="*" UpgradeCode="{919F5399-4E7A-4D8A-9484-A85D0F5E2C77}" ProductName="ProductName-2" />
  <Instance Id="I3" ProductCode="*" UpgradeCode="{0BEAEF92-1821-4909-A83A-9B2AE2194AAC}" ProductName="ProductName-3" />
</InstanceTransforms>

, ( ), * ProductCode UpgradeCode, MajorUpgrades , . , ProductName Add/Remove program .

:

msiexec /I ProductName.msi

:

msiexec /I ProductName.msi MSINEWINSTANCE=1 TRANSFORMS=":I1"
msiexec /I ProductName.msi MSINEWINSTANCE=1 TRANSFORMS=":I2"
msiexec /I ProductName.msi MSINEWINSTANCE=1 TRANSFORMS=":I3"

":" TRANSFORMS. .

.

+3

Source: https://habr.com/ru/post/1535323/


All Articles