@joebigelow / wix-1 / commits / 59f37d21

Fix the use of ModuleSubstitution table

Addresses two issues in the creation of configurable merge modules. First, the ModuleConfiguration table Id should not be modularized. Second, the ModuleSubstitution table was never created. Fixing both of those allows configurable merge modules to work again. Fixes 7559

Rob Mensching committed Aug 7, 2023 at 15:43 UTC 59f37d218f58ef80da541a11a1d3825554c00d3f
6 files changed +93 -3
src/api/wix/WixToolset.Data/WindowsInstaller/WindowsInstallerTableDefinitions.cs
+1 -1
@@ -1455,7 +1455,7 @@ namespace WixToolset.Data.WindowsInstaller
1455 SymbolDefinitions.ModuleConfiguration,
1456 new[]
1457 {
1458 - new ColumnDefinition("Name", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "Unique identifier for this row."),
1458 + new ColumnDefinition("Name", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "Unique identifier for this row.", modularizeType: ColumnModularizeType.None),
1459 new ColumnDefinition("Format", ColumnType.Number, 2, primaryKey: false, nullable: false, ColumnCategory.Unknown, minValue: 0, maxValue: 3, description: "Format of this item."),
1460 new ColumnDefinition("Type", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Text, description: "Additional type information for this item."),
1461 new ColumnDefinition("ContextData", ColumnType.Localized, 0, primaryKey: false, nullable: true, ColumnCategory.Text, description: "Additional context information about this item."),
src/wix/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs
+5 -2
@@ -58,7 +58,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
58
59 private IWindowsInstallerBackendHelper WindowsInstallerBackendHelper { get; }
60
61 - private IFileSystem FileSystem { get; }
61 + private IFileSystem FileSystem { get; }
62
63 private IPathResolver PathResolver { get; }
64
@@ -477,7 +477,10 @@ namespace WixToolset.Core.WindowsInstaller.Bind
477 var command = new MergeModulesCommand(this.Messaging, this.WindowsInstallerBackendHelper, fileFacadesFromModule, section, suppressedTableNames, this.OutputPath, this.IntermediateFolder);
478 command.Execute();
479
480 - trackedFiles.AddRange(command.TrackedFiles);
480 + if (command.TrackedFiles != null)
481 + {
482 + trackedFiles.AddRange(command.TrackedFiles);
483 + }
484 }
485
486 if (this.Messaging.EncounteredError)
src/wix/WixToolset.Core.WindowsInstaller/Bind/CreateWindowsInstallerDataFromIRCommand.cs
+1
@@ -148,6 +148,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
148 break;
149
150 case SymbolDefinitionType.ModuleSubstitution:
151 + this.AddSymbolDefaultly(symbol);
152 this.EnsureModuleIgnoredTable(symbol, "ModuleSubstitution");
153 break;
154
src/wix/test/WixToolsetTest.CoreIntegration/ModuleFixture.cs
+58
@@ -13,6 +13,64 @@ namespace WixToolsetTest.CoreIntegration
13
14 public class ModuleFixture
15 {
16 + [Fact]
17 + public void CanBuildAndMergeModuleWithSubstitution()
18 + {
19 + var folder = TestData.Get(@"TestData", "Module");
20 +
21 + using (var fs = new DisposableFileSystem())
22 + {
23 + var intermediateFolder = fs.GetFolder();
24 + var msmIntermediatePath = Path.Combine(intermediateFolder, "msm");
25 + var msmPath = Path.Combine(msmIntermediatePath, "test.msm");
26 +
27 + var msiIntermediatePath = Path.Combine(intermediateFolder, "msi");
28 + var msiPath = Path.Combine(msiIntermediatePath, "test.msi");
29 +
30 + // Build the MSM.
31 + var result = WixRunner.Execute(new[]
32 + {
33 + "build",
34 + Path.Combine(folder, "ModuleSubstitution.wxs"),
35 + "-intermediateFolder", msmIntermediatePath,
36 + "-sw1079",
37 + "-o", msmPath
38 + });
39 +
40 + result.AssertSuccess();
41 +
42 + // Verify the MSM.
43 + var rows = Query.QueryDatabase(msmPath, new[] { "CustomAction", "ModuleConfiguration", "ModuleSubstitution" });
44 + WixAssert.CompareLineByLine(new[]
45 + {
46 + "CustomAction:setCONFIGTEST.DC68E039_E0C8_49FB_B5E6_37F9569188E5\t51\tmsmCONFIGTEST.DC68E039_E0C8_49FB_B5E6_37F9569188E5\t[msmCONFIGTEST.DC68E039_E0C8_49FB_B5E6_37F9569188E5]\t",
47 + "ModuleConfiguration:CONFIGTEST\t0\t\t\t\t0\t\t\t\t",
48 + "ModuleSubstitution:CustomAction\tsetCONFIGTEST.DC68E039_E0C8_49FB_B5E6_37F9569188E5\tTarget\t[=CONFIGTEST]"
49 + }, rows);
50 +
51 + // Merge the module into an MSI.
52 + result = WixRunner.Execute(new[]
53 + {
54 + "build",
55 + Path.Combine(folder, "MergeModuleSubstitution.wxs"),
56 + "-bindpath", msmIntermediatePath,
57 + "-intermediateFolder", msiIntermediatePath,
58 + "-o", msiPath
59 + });
60 +
61 + result.AssertSuccess();
62 +
63 + // Verify the MSI.
64 + rows = Query.QueryDatabase(msiPath, new[] { "CustomAction", "ModuleConfiguration", "ModuleSubstitution" });
65 + WixAssert.CompareLineByLine(new[]
66 + {
67 + "CustomAction:setCONFIGTEST.DC68E039_E0C8_49FB_B5E6_37F9569188E5\t51\tmsmCONFIGTEST.DC68E039_E0C8_49FB_B5E6_37F9569188E5\tTestingTesting123\t"
68 + }, rows);
69 +
70 + result.AssertSuccess();
71 + }
72 + }
73 +
74 [Fact]
75 public void CanSuppressModularization()
76 {
src/wix/test/WixToolsetTest.CoreIntegration/TestData/Module/MergeModuleSubstitution.wxs new
+17
@@ -0,0 +1,17 @@
1 +<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
2 + <Package Name="MergeModuleSubstitution" Language="1033" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a">
3 + <MajorUpgrade DowngradeErrorMessage="Downgrade message" />
4 +
5 + <Feature Id="Main">
6 + <MergeRef Id="TestMsm" />
7 + </Feature>
8 +
9 + <StandardDirectory Id="ProgramFilesFolder">
10 + <Directory Id="INSTALLFOLDER" Name="MsiPackage">
11 + <Merge Id="TestMsm" Language="1033" SourceFile="test.msm">
12 + <ConfigurationData Name="CONFIGTEST" Value="TestingTesting123" />
13 + </Merge>
14 + </Directory>
15 + </StandardDirectory>
16 + </Package>
17 +</Wix>
src/wix/test/WixToolsetTest.CoreIntegration/TestData/Module/ModuleSubstitution.wxs new
+11
@@ -0,0 +1,11 @@
1 +<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
2 + <Module Id="MergeModule.v4" Guid="dc68e039-e0c8-49fb-b5e6-37f9569188e5" Language="1033" Version="1.0.0.0">
3 + <SummaryInformation Manufacturer="Manufacturer" />
4 +
5 + <Configuration Name='CONFIGTEST' Format='Text'/>
6 + <Substitution Table='CustomAction' Row='setCONFIGTEST' Column='Target' Value='[=CONFIGTEST]'/>
7 +
8 + <Property Id="msmCONFIGTEST" Value="failure"/>
9 + <CustomAction Id='setCONFIGTEST' Property='msmCONFIGTEST' Value='[msmCONFIGTEST]'/>
10 + </Module>
11 +</Wix>