From 205215078d3b7bd9c7459307bc792d52ec404760 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Mon, 7 Aug 2023 15:43:10 -0700 Subject: 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 --- .../WindowsInstallerTableDefinitions.cs | 2 +- .../Bind/BindDatabaseCommand.cs | 7 ++- .../CreateWindowsInstallerDataFromIRCommand.cs | 1 + .../ModuleFixture.cs | 58 ++++++++++++++++++++++ .../TestData/Module/MergeModuleSubstitution.wxs | 17 +++++++ .../TestData/Module/ModuleSubstitution.wxs | 11 ++++ 6 files changed, 93 insertions(+), 3 deletions(-) create mode 100644 src/wix/test/WixToolsetTest.CoreIntegration/TestData/Module/MergeModuleSubstitution.wxs create mode 100644 src/wix/test/WixToolsetTest.CoreIntegration/TestData/Module/ModuleSubstitution.wxs diff --git a/src/api/wix/WixToolset.Data/WindowsInstaller/WindowsInstallerTableDefinitions.cs b/src/api/wix/WixToolset.Data/WindowsInstaller/WindowsInstallerTableDefinitions.cs index b0fde6a7..9f0cdd96 100644 --- a/src/api/wix/WixToolset.Data/WindowsInstaller/WindowsInstallerTableDefinitions.cs +++ b/src/api/wix/WixToolset.Data/WindowsInstaller/WindowsInstallerTableDefinitions.cs @@ -1455,7 +1455,7 @@ namespace WixToolset.Data.WindowsInstaller SymbolDefinitions.ModuleConfiguration, new[] { - new ColumnDefinition("Name", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "Unique identifier for this row."), + new ColumnDefinition("Name", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "Unique identifier for this row.", modularizeType: ColumnModularizeType.None), new ColumnDefinition("Format", ColumnType.Number, 2, primaryKey: false, nullable: false, ColumnCategory.Unknown, minValue: 0, maxValue: 3, description: "Format of this item."), new ColumnDefinition("Type", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Text, description: "Additional type information for this item."), new ColumnDefinition("ContextData", ColumnType.Localized, 0, primaryKey: false, nullable: true, ColumnCategory.Text, description: "Additional context information about this item."), diff --git a/src/wix/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs b/src/wix/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs index a1ec24f4..4db1bfbe 100644 --- a/src/wix/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs +++ b/src/wix/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs @@ -58,7 +58,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind private IWindowsInstallerBackendHelper WindowsInstallerBackendHelper { get; } - private IFileSystem FileSystem { get; } + private IFileSystem FileSystem { get; } private IPathResolver PathResolver { get; } @@ -477,7 +477,10 @@ namespace WixToolset.Core.WindowsInstaller.Bind var command = new MergeModulesCommand(this.Messaging, this.WindowsInstallerBackendHelper, fileFacadesFromModule, section, suppressedTableNames, this.OutputPath, this.IntermediateFolder); command.Execute(); - trackedFiles.AddRange(command.TrackedFiles); + if (command.TrackedFiles != null) + { + trackedFiles.AddRange(command.TrackedFiles); + } } if (this.Messaging.EncounteredError) diff --git a/src/wix/WixToolset.Core.WindowsInstaller/Bind/CreateWindowsInstallerDataFromIRCommand.cs b/src/wix/WixToolset.Core.WindowsInstaller/Bind/CreateWindowsInstallerDataFromIRCommand.cs index 18914745..234cad4a 100644 --- a/src/wix/WixToolset.Core.WindowsInstaller/Bind/CreateWindowsInstallerDataFromIRCommand.cs +++ b/src/wix/WixToolset.Core.WindowsInstaller/Bind/CreateWindowsInstallerDataFromIRCommand.cs @@ -148,6 +148,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind break; case SymbolDefinitionType.ModuleSubstitution: + this.AddSymbolDefaultly(symbol); this.EnsureModuleIgnoredTable(symbol, "ModuleSubstitution"); break; diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/ModuleFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/ModuleFixture.cs index eadc70aa..3e42431e 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/ModuleFixture.cs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/ModuleFixture.cs @@ -13,6 +13,64 @@ namespace WixToolsetTest.CoreIntegration public class ModuleFixture { + [Fact] + public void CanBuildAndMergeModuleWithSubstitution() + { + var folder = TestData.Get(@"TestData", "Module"); + + using (var fs = new DisposableFileSystem()) + { + var intermediateFolder = fs.GetFolder(); + var msmIntermediatePath = Path.Combine(intermediateFolder, "msm"); + var msmPath = Path.Combine(msmIntermediatePath, "test.msm"); + + var msiIntermediatePath = Path.Combine(intermediateFolder, "msi"); + var msiPath = Path.Combine(msiIntermediatePath, "test.msi"); + + // Build the MSM. + var result = WixRunner.Execute(new[] + { + "build", + Path.Combine(folder, "ModuleSubstitution.wxs"), + "-intermediateFolder", msmIntermediatePath, + "-sw1079", + "-o", msmPath + }); + + result.AssertSuccess(); + + // Verify the MSM. + var rows = Query.QueryDatabase(msmPath, new[] { "CustomAction", "ModuleConfiguration", "ModuleSubstitution" }); + WixAssert.CompareLineByLine(new[] + { + "CustomAction:setCONFIGTEST.DC68E039_E0C8_49FB_B5E6_37F9569188E5\t51\tmsmCONFIGTEST.DC68E039_E0C8_49FB_B5E6_37F9569188E5\t[msmCONFIGTEST.DC68E039_E0C8_49FB_B5E6_37F9569188E5]\t", + "ModuleConfiguration:CONFIGTEST\t0\t\t\t\t0\t\t\t\t", + "ModuleSubstitution:CustomAction\tsetCONFIGTEST.DC68E039_E0C8_49FB_B5E6_37F9569188E5\tTarget\t[=CONFIGTEST]" + }, rows); + + // Merge the module into an MSI. + result = WixRunner.Execute(new[] + { + "build", + Path.Combine(folder, "MergeModuleSubstitution.wxs"), + "-bindpath", msmIntermediatePath, + "-intermediateFolder", msiIntermediatePath, + "-o", msiPath + }); + + result.AssertSuccess(); + + // Verify the MSI. + rows = Query.QueryDatabase(msiPath, new[] { "CustomAction", "ModuleConfiguration", "ModuleSubstitution" }); + WixAssert.CompareLineByLine(new[] + { + "CustomAction:setCONFIGTEST.DC68E039_E0C8_49FB_B5E6_37F9569188E5\t51\tmsmCONFIGTEST.DC68E039_E0C8_49FB_B5E6_37F9569188E5\tTestingTesting123\t" + }, rows); + + result.AssertSuccess(); + } + } + [Fact] public void CanSuppressModularization() { diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Module/MergeModuleSubstitution.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Module/MergeModuleSubstitution.wxs new file mode 100644 index 00000000..0afd79b2 --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Module/MergeModuleSubstitution.wxs @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Module/ModuleSubstitution.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Module/ModuleSubstitution.wxs new file mode 100644 index 00000000..0ada31b9 --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Module/ModuleSubstitution.wxs @@ -0,0 +1,11 @@ + + + + + + + + + + + -- cgit v1.2.3-55-g6feb