From 718dce937b6c8aa0abe309364d3f298d206f4aae Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Sun, 6 Feb 2022 09:52:51 -0800 Subject: Fix several bugs with Merge Modules --- .../WixToolset.Core.Native.csproj | 15 +++++--------- .../Bind/ExtractMergeModuleFilesCommand.cs | 9 ++++++-- .../Bind/UpdateMediaSequencesCommand.cs | 2 +- src/wix/WixToolset.Core/Compiler_Module.cs | 20 +++++++++++++++++- src/wix/WixToolset.Core/Compiler_Package.cs | 24 +++++++++++----------- .../MsiQueryFixture.cs | 23 +++++++++++++++++---- .../TestData/SimpleModule/Module.wxs | 4 ++-- 7 files changed, 65 insertions(+), 32 deletions(-) diff --git a/src/wix/WixToolset.Core.Native/WixToolset.Core.Native.csproj b/src/wix/WixToolset.Core.Native/WixToolset.Core.Native.csproj index 619b85b6..30c0b845 100644 --- a/src/wix/WixToolset.Core.Native/WixToolset.Core.Native.csproj +++ b/src/wix/WixToolset.Core.Native/WixToolset.Core.Native.csproj @@ -24,16 +24,11 @@ - - - - - - - - - - + + + + + diff --git a/src/wix/WixToolset.Core.WindowsInstaller/Bind/ExtractMergeModuleFilesCommand.cs b/src/wix/WixToolset.Core.WindowsInstaller/Bind/ExtractMergeModuleFilesCommand.cs index 7c1e085c..aac4dd4f 100644 --- a/src/wix/WixToolset.Core.WindowsInstaller/Bind/ExtractMergeModuleFilesCommand.cs +++ b/src/wix/WixToolset.Core.WindowsInstaller/Bind/ExtractMergeModuleFilesCommand.cs @@ -91,17 +91,22 @@ namespace WixToolset.Core.WindowsInstaller.Bind { var uniqueModuleFileIdentifiers = new Dictionary(StringComparer.OrdinalIgnoreCase); - using (var view = db.OpenExecuteView("SELECT `File`, `Directory_` FROM `File`, `Component` WHERE `Component_`=`Component`")) + using (var view = db.OpenExecuteView("SELECT `File`, `Component_`, `FileName`, `Directory_` FROM `File`, `Component` WHERE `Component_`=`Component`")) { // add each file row from the merge module into the file row collection (check for errors along the way) foreach (var record in view.Records) { + var splitFilename = this.BackendHelper.SplitMsiFileName(record[3]); + // NOTE: this is very tricky - the merge module file rows are not added to the // file table because they should not be created via idt import. Instead, these // rows are created by merging in the actual modules. var fileSymbol = new FileSymbol(wixMergeRow.SourceLineNumbers, new Identifier(AccessModifier.Section, record[1])); fileSymbol.Attributes = wixMergeRow.FileAttributes; - fileSymbol.DirectoryRef = record[2]; + fileSymbol.ComponentRef = record[2]; + fileSymbol.Name = splitFilename[1] ?? splitFilename[0]; + fileSymbol.ShortName = splitFilename[1] is null ? null : splitFilename[0]; + fileSymbol.DirectoryRef = record[4]; fileSymbol.DiskId = wixMergeRow.DiskId; fileSymbol.Source = new IntermediateFieldPathValue { Path = Path.Combine(this.IntermediateFolder, wixMergeRow.Id.Id, record[1]) }; diff --git a/src/wix/WixToolset.Core.WindowsInstaller/Bind/UpdateMediaSequencesCommand.cs b/src/wix/WixToolset.Core.WindowsInstaller/Bind/UpdateMediaSequencesCommand.cs index affec09f..e0ed56b1 100644 --- a/src/wix/WixToolset.Core.WindowsInstaller/Bind/UpdateMediaSequencesCommand.cs +++ b/src/wix/WixToolset.Core.WindowsInstaller/Bind/UpdateMediaSequencesCommand.cs @@ -68,7 +68,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind patchGroup.Add(facade); } - else if (!facade.FromModule) + else { facade.Sequence = ++lastSequence; } diff --git a/src/wix/WixToolset.Core/Compiler_Module.cs b/src/wix/WixToolset.Core/Compiler_Module.cs index 3986c8da..7b708981 100644 --- a/src/wix/WixToolset.Core/Compiler_Module.cs +++ b/src/wix/WixToolset.Core/Compiler_Module.cs @@ -249,7 +249,7 @@ namespace WixToolset.Core this.Core.AddSymbol(new SummaryInformationSymbol(sourceLineNumbers) { PropertyId = SummaryInformationType.Keywords, - Value = "Installer" + Value = "MergeModule, MSI, database" }); } @@ -266,6 +266,24 @@ namespace WixToolset.Core Value = moduleId }); + this.Core.AddSymbol(new SummaryInformationSymbol(sourceLineNumbers) + { + PropertyId = SummaryInformationType.Title, + Value = "Merge Module" + }); + + this.Core.AddSymbol(new SummaryInformationSymbol(sourceLineNumbers) + { + PropertyId = SummaryInformationType.WordCount, + Value = "0" + }); + + this.Core.AddSymbol(new SummaryInformationSymbol(sourceLineNumbers) + { + PropertyId = SummaryInformationType.Comments, + Value = String.Format(CultureInfo.InvariantCulture, "This merge module contains the logic and data required to install {0}.", this.activeName) + }); + this.ValidateAndAddCommonSummaryInformationSymbols(sourceLineNumbers, msiVersion, platform, this.activeLanguage); } } diff --git a/src/wix/WixToolset.Core/Compiler_Package.cs b/src/wix/WixToolset.Core/Compiler_Package.cs index d3db2e80..d969decb 100644 --- a/src/wix/WixToolset.Core/Compiler_Package.cs +++ b/src/wix/WixToolset.Core/Compiler_Package.cs @@ -182,6 +182,18 @@ namespace WixToolset.Core this.AddProperty(sourceLineNumbers, new Identifier(AccessModifier.Global, "ALLUSERS"), "1", false, false, false, false); } + this.Core.AddSymbol(new SummaryInformationSymbol(sourceLineNumbers) + { + PropertyId = SummaryInformationType.Title, + Value = "Installation Database" + }); + + this.Core.AddSymbol(new SummaryInformationSymbol(sourceLineNumbers) + { + PropertyId = SummaryInformationType.Comments, + Value = String.Format(CultureInfo.InvariantCulture, "This installer database contains the logic and data required to install {0}.", this.activeName) + }); + this.ValidateAndAddCommonSummaryInformationSymbols(sourceLineNumbers, msiVersion, platform, productLanguage); this.Core.AddSymbol(new SummaryInformationSymbol(sourceLineNumbers) @@ -449,18 +461,6 @@ namespace WixToolset.Core this.Core.Write(WarningMessages.RequiresMsi500forArmPackage(sourceLineNumbers)); } - this.Core.AddSymbol(new SummaryInformationSymbol(sourceLineNumbers) - { - PropertyId = SummaryInformationType.Comments, - Value = String.Format(CultureInfo.InvariantCulture, "This installer database contains the logic and data required to install {0}.", this.activeName) - }); - - this.Core.AddSymbol(new SummaryInformationSymbol(sourceLineNumbers) - { - PropertyId = SummaryInformationType.Title, - Value = "Installation Database" - }); - this.Core.AddSymbol(new SummaryInformationSymbol(sourceLineNumbers) { PropertyId = SummaryInformationType.PlatformAndLanguage, diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/MsiQueryFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/MsiQueryFixture.cs index 7489bb47..2b3bfc88 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/MsiQueryFixture.cs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/MsiQueryFixture.cs @@ -834,9 +834,10 @@ namespace WixToolsetTest.CoreIntegration } } - [Fact(Skip = "Test fails in new repo")] + [Fact] public void CanMergeModule() { + var msmFolder = TestData.Get(@"TestData\SimpleModule"); var folder = TestData.Get(@"TestData\SimpleMerge"); using (var fs = new DisposableFileSystem()) @@ -845,12 +846,24 @@ namespace WixToolsetTest.CoreIntegration var msiPath = Path.Combine(intermediateFolder, @"bin\test.msi"); var cabPath = Path.Combine(intermediateFolder, @"bin\cab1.cab"); + var msmResult = WixRunner.Execute(new[] + { + "build", + Path.Combine(msmFolder, "Module.wxs"), + "-loc", Path.Combine(msmFolder, "Module.en-us.wxl"), + "-bindpath", Path.Combine(msmFolder, "data"), + "-intermediateFolder", intermediateFolder, + "-o", Path.Combine(intermediateFolder, "bin", "test", "test.msm") + }); + + msmResult.AssertSuccess(); + var result = WixRunner.Execute(new[] { "build", Path.Combine(folder, "Package.wxs"), "-loc", Path.Combine(folder, "Package.en-us.wxl"), - "-bindpath", Path.Combine(folder, ".data"), + "-bindpath", Path.Combine(intermediateFolder, "bin", "test"), "-intermediateFolder", intermediateFolder, "-o", msiPath }); @@ -870,13 +883,15 @@ namespace WixToolsetTest.CoreIntegration var results = Query.QueryDatabase(msiPath, new[] { "File" }); WixAssert.CompareLineByLine(new[] { - "File:filyIq8rqcxxf903Hsn5K9L0SWV73g.243FB739_4D05_472F_9CFB_EF6B1017B6DE\tModuleComponent.243FB739_4D05_472F_9CFB_EF6B1017B6DE\ttest.txt\t17\t\t\t512\t0" + "File:File1.243FB739_4D05_472F_9CFB_EF6B1017B6DE\tModuleComponent1.243FB739_4D05_472F_9CFB_EF6B1017B6DE\tfile1.txt\t17\t\t\t512\t1", + "File:File2.243FB739_4D05_472F_9CFB_EF6B1017B6DE\tModuleComponent2.243FB739_4D05_472F_9CFB_EF6B1017B6DE\tfile2.txt\t17\t\t\t512\t2", }, results); var files = Query.GetCabinetFiles(cabPath); WixAssert.CompareLineByLine(new[] { - "filyIq8rqcxxf903Hsn5K9L0SWV73g.243FB739_4D05_472F_9CFB_EF6B1017B6DE" + "File1.243FB739_4D05_472F_9CFB_EF6B1017B6DE", + "File2.243FB739_4D05_472F_9CFB_EF6B1017B6DE" }, files.Select(f => f.Name).ToArray()); } } diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/SimpleModule/Module.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/SimpleModule/Module.wxs index 8317e7af..0b0ce141 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/SimpleModule/Module.wxs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/SimpleModule/Module.wxs @@ -4,13 +4,13 @@ - + - + -- cgit v1.2.3-55-g6feb