diff options
| author | Bob Arnson <bob@firegiant.com> | 2023-06-20 20:09:19 -0400 |
|---|---|---|
| committer | Bob Arnson <github@bobs.org> | 2023-06-21 16:56:11 -0400 |
| commit | ddae99c27fcec6c90696f6df66608aae155d6a93 (patch) | |
| tree | 3097010e0c1b753d9fc2f4d75ce43388e355e5d5 | |
| parent | 9a550ac1bd6dbe1d3957fd3069115ac9db78251b (diff) | |
| download | wix-ddae99c27fcec6c90696f6df66608aae155d6a93.tar.gz wix-ddae99c27fcec6c90696f6df66608aae155d6a93.tar.bz2 wix-ddae99c27fcec6c90696f6df66608aae155d6a93.zip | |
Handle MergeModule.CABinet for extraction.
Fixes https://github.com/wixtoolset/issues/issues/7568,
Diffstat (limited to '')
3 files changed, 36 insertions, 16 deletions
diff --git a/src/wix/WixToolset.Core.WindowsInstaller/Unbind/ExtractCabinetsCommand.cs b/src/wix/WixToolset.Core.WindowsInstaller/Unbind/ExtractCabinetsCommand.cs index 5ac7efe6..ba6877c8 100644 --- a/src/wix/WixToolset.Core.WindowsInstaller/Unbind/ExtractCabinetsCommand.cs +++ b/src/wix/WixToolset.Core.WindowsInstaller/Unbind/ExtractCabinetsCommand.cs | |||
| @@ -29,7 +29,7 @@ namespace WixToolset.Core.WindowsInstaller.Unbind | |||
| 29 | 29 | ||
| 30 | public Dictionary<string, MediaRow> ExtractedFileIdsWithMediaRow { get; private set; } | 30 | public Dictionary<string, MediaRow> ExtractedFileIdsWithMediaRow { get; private set; } |
| 31 | 31 | ||
| 32 | private IFileSystem FileSystem { get; } | 32 | private IFileSystem FileSystem { get; } |
| 33 | 33 | ||
| 34 | private WindowsInstallerData Output { get; } | 34 | private WindowsInstallerData Output { get; } |
| 35 | 35 | ||
| @@ -55,13 +55,23 @@ namespace WixToolset.Core.WindowsInstaller.Unbind | |||
| 55 | // index all of the cabinet files | 55 | // index all of the cabinet files |
| 56 | if (OutputType.Module == this.Output.Type || this.TreatOutputAsModule) | 56 | if (OutputType.Module == this.Output.Type || this.TreatOutputAsModule) |
| 57 | { | 57 | { |
| 58 | embeddedCabinetNamesByDiskId.Add(0, "MergeModule.CABinet"); | 58 | var mediaRow = new MediaRow(null, WindowsInstallerTableDefinitions.Media) |
| 59 | { | ||
| 60 | DiskId = 1, | ||
| 61 | LastSequence = 1, | ||
| 62 | Cabinet = "MergeModule.CABinet", | ||
| 63 | }; | ||
| 64 | |||
| 65 | embeddedCabinetRowsByDiskId.Add(1, mediaRow); | ||
| 66 | embeddedCabinetNamesByDiskId.Add(1, "MergeModule.CABinet"); | ||
| 59 | } | 67 | } |
| 60 | else if (this.Output.Tables.TryGetTable("Media", out var mediaTable)) | 68 | |
| 69 | if (this.Output.Tables.TryGetTable("Media", out var mediaTable)) | ||
| 61 | { | 70 | { |
| 62 | foreach (var mediaRow in mediaTable.Rows.Cast<MediaRow>().Where(r => !String.IsNullOrEmpty(r.Cabinet))) | 71 | foreach (var mediaRow in mediaTable.Rows.Cast<MediaRow>().Where(r => !String.IsNullOrEmpty(r.Cabinet))) |
| 63 | { | 72 | { |
| 64 | if (OutputType.Package == this.Output.Type || | 73 | if (OutputType.Package == this.Output.Type || |
| 74 | OutputType.Module == this.Output.Type || | ||
| 65 | (OutputType.Transform == this.Output.Type && RowOperation.Add == mediaRow.Operation)) | 75 | (OutputType.Transform == this.Output.Type && RowOperation.Add == mediaRow.Operation)) |
| 66 | { | 76 | { |
| 67 | if (mediaRow.Cabinet.StartsWith("#", StringComparison.Ordinal)) | 77 | if (mediaRow.Cabinet.StartsWith("#", StringComparison.Ordinal)) |
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/DecompileFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/DecompileFixture.cs index a4915a3a..6a9de6df 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/DecompileFixture.cs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/DecompileFixture.cs | |||
| @@ -2,20 +2,22 @@ | |||
| 2 | 2 | ||
| 3 | namespace WixToolsetTest.CoreIntegration | 3 | namespace WixToolsetTest.CoreIntegration |
| 4 | { | 4 | { |
| 5 | using System; | ||
| 5 | using System.IO; | 6 | using System.IO; |
| 6 | using WixInternal.TestSupport; | ||
| 7 | using WixInternal.Core.TestPackage; | 7 | using WixInternal.Core.TestPackage; |
| 8 | using WixInternal.TestSupport; | ||
| 8 | using Xunit; | 9 | using Xunit; |
| 9 | 10 | ||
| 10 | public class DecompileFixture | 11 | public class DecompileFixture |
| 11 | { | 12 | { |
| 12 | private static void DecompileAndCompare(string msiName, string expectedWxsName, params string[] sourceFolder) | 13 | private static void DecompileAndCompare(string msiName, bool extract, string expectedWxsName, params string[] sourceFolder) |
| 13 | { | 14 | { |
| 14 | var folder = TestData.Get(sourceFolder); | 15 | var folder = TestData.Get(sourceFolder); |
| 15 | 16 | ||
| 16 | using (var fs = new DisposableFileSystem()) | 17 | using (var fs = new DisposableFileSystem()) |
| 17 | { | 18 | { |
| 18 | var intermediateFolder = fs.GetFolder(); | 19 | var intermediateFolder = fs.GetFolder(); |
| 20 | var extractPath = Path.Combine(intermediateFolder, "$extracted"); | ||
| 19 | var outputPath = Path.Combine(intermediateFolder, @"Actual.wxs"); | 21 | var outputPath = Path.Combine(intermediateFolder, @"Actual.wxs"); |
| 20 | 22 | ||
| 21 | var result = WixRunner.Execute(new[] | 23 | var result = WixRunner.Execute(new[] |
| @@ -23,10 +25,18 @@ namespace WixToolsetTest.CoreIntegration | |||
| 23 | "msi", "decompile", | 25 | "msi", "decompile", |
| 24 | Path.Combine(folder, msiName), | 26 | Path.Combine(folder, msiName), |
| 25 | "-intermediateFolder", intermediateFolder, | 27 | "-intermediateFolder", intermediateFolder, |
| 26 | "-o", outputPath | 28 | "-o", outputPath, |
| 29 | extract ? "-x" : String.Empty, | ||
| 30 | extract ? extractPath : String.Empty, | ||
| 27 | }, out var messages); | 31 | }, out var messages); |
| 28 | 32 | ||
| 29 | Assert.Equal(0, result); | 33 | Assert.Equal(0, result); |
| 34 | Assert.Empty(messages); | ||
| 35 | |||
| 36 | if (extract) | ||
| 37 | { | ||
| 38 | Assert.NotEmpty(Directory.EnumerateFiles(extractPath, "*", SearchOption.AllDirectories)); | ||
| 39 | } | ||
| 30 | 40 | ||
| 31 | WixAssert.CompareXml(Path.Combine(folder, expectedWxsName), outputPath); | 41 | WixAssert.CompareXml(Path.Combine(folder, expectedWxsName), outputPath); |
| 32 | } | 42 | } |
| @@ -35,19 +45,19 @@ namespace WixToolsetTest.CoreIntegration | |||
| 35 | [Fact] | 45 | [Fact] |
| 36 | public void CanDecompileSingleFileCompressed() | 46 | public void CanDecompileSingleFileCompressed() |
| 37 | { | 47 | { |
| 38 | DecompileAndCompare("example.msi", "Expected.wxs", "TestData", "DecompileSingleFileCompressed"); | 48 | DecompileAndCompare("example.msi", extract: true, "Expected.wxs", "TestData", "DecompileSingleFileCompressed"); |
| 39 | } | 49 | } |
| 40 | 50 | ||
| 41 | [Fact] | 51 | [Fact] |
| 42 | public void CanDecompile64BitSingleFileCompressed() | 52 | public void CanDecompile64BitSingleFileCompressed() |
| 43 | { | 53 | { |
| 44 | DecompileAndCompare("example.msi", "Expected.wxs", "TestData", "DecompileSingleFileCompressed64"); | 54 | DecompileAndCompare("example.msi", extract: true, "Expected.wxs", "TestData", "DecompileSingleFileCompressed64"); |
| 45 | } | 55 | } |
| 46 | 56 | ||
| 47 | [Fact] | 57 | [Fact] |
| 48 | public void CanDecompileNestedDirSearchUnderRegSearch() | 58 | public void CanDecompileNestedDirSearchUnderRegSearch() |
| 49 | { | 59 | { |
| 50 | DecompileAndCompare("NestedDirSearchUnderRegSearch.msi", "DecompiledNestedDirSearchUnderRegSearch.wxs", "TestData", "AppSearch"); | 60 | DecompileAndCompare("NestedDirSearchUnderRegSearch.msi", extract: false, "DecompiledNestedDirSearchUnderRegSearch.wxs", "TestData", "AppSearch"); |
| 51 | } | 61 | } |
| 52 | 62 | ||
| 53 | [Fact] | 63 | [Fact] |
| @@ -56,37 +66,37 @@ namespace WixToolsetTest.CoreIntegration | |||
| 56 | // The input MSI was not created using standard methods, it is an example of a real world database that needs to be decompiled. | 66 | // The input MSI was not created using standard methods, it is an example of a real world database that needs to be decompiled. |
| 57 | // The Class/@Feature_ column has length of 32, the File/@Attributes has length of 2, | 67 | // The Class/@Feature_ column has length of 32, the File/@Attributes has length of 2, |
| 58 | // and numerous foreign key relationships are missing. | 68 | // and numerous foreign key relationships are missing. |
| 59 | DecompileAndCompare("OldClassTableDef.msi", "DecompiledOldClassTableDef.wxs", "TestData", "Class"); | 69 | DecompileAndCompare("OldClassTableDef.msi", extract: false, "DecompiledOldClassTableDef.wxs", "TestData", "Class"); |
| 60 | } | 70 | } |
| 61 | 71 | ||
| 62 | [Fact] | 72 | [Fact] |
| 63 | public void CanDecompileSequenceTables() | 73 | public void CanDecompileSequenceTables() |
| 64 | { | 74 | { |
| 65 | DecompileAndCompare("SequenceTables.msi", "DecompiledSequenceTables.wxs", "TestData", "SequenceTables"); | 75 | DecompileAndCompare("SequenceTables.msi", extract: false, "DecompiledSequenceTables.wxs", "TestData", "SequenceTables"); |
| 66 | } | 76 | } |
| 67 | 77 | ||
| 68 | [Fact] | 78 | [Fact] |
| 69 | public void CanDecompileShortcuts() | 79 | public void CanDecompileShortcuts() |
| 70 | { | 80 | { |
| 71 | DecompileAndCompare("shortcuts.msi", "DecompiledShortcuts.wxs", "TestData", "Shortcut"); | 81 | DecompileAndCompare("shortcuts.msi", extract: false, "DecompiledShortcuts.wxs", "TestData", "Shortcut"); |
| 72 | } | 82 | } |
| 73 | 83 | ||
| 74 | [Fact] | 84 | [Fact] |
| 75 | public void CanDecompileNullComponent() | 85 | public void CanDecompileNullComponent() |
| 76 | { | 86 | { |
| 77 | DecompileAndCompare("example.msi", "Expected.wxs", "TestData", "DecompileNullComponent"); | 87 | DecompileAndCompare("example.msi", extract: true, "Expected.wxs", "TestData", "DecompileNullComponent"); |
| 78 | } | 88 | } |
| 79 | 89 | ||
| 80 | [Fact] | 90 | [Fact] |
| 81 | public void CanDecompileMergeModuleWithTargetDirComponent() | 91 | public void CanDecompileMergeModuleWithTargetDirComponent() |
| 82 | { | 92 | { |
| 83 | DecompileAndCompare("MergeModule1.msm", "Expected.wxs", "TestData", "DecompileTargetDirMergeModule"); | 93 | DecompileAndCompare("MergeModule1.msm", extract: true, "Expected.wxs", "TestData", "DecompileTargetDirMergeModule"); |
| 84 | } | 94 | } |
| 85 | 95 | ||
| 86 | [Fact] | 96 | [Fact] |
| 87 | public void CanDecompileUI() | 97 | public void CanDecompileUI() |
| 88 | { | 98 | { |
| 89 | DecompileAndCompare("ui.msi", "ExpectedUI.wxs", "TestData", "Decompile"); | 99 | DecompileAndCompare("ui.msi", extract: false, "ExpectedUI.wxs", "TestData", "Decompile"); |
| 90 | } | 100 | } |
| 91 | } | 101 | } |
| 92 | } | 102 | } |
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/PatchFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/PatchFixture.cs index d07793a1..82dfc7e5 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/PatchFixture.cs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/PatchFixture.cs | |||
| @@ -575,7 +575,7 @@ namespace WixToolsetTest.CoreIntegration | |||
| 575 | var args = $"/a \"{Path.ChangeExtension(msiPath, "msi")}\" TARGETDIR=\"{targetDir}\" /qn"; | 575 | var args = $"/a \"{Path.ChangeExtension(msiPath, "msi")}\" TARGETDIR=\"{targetDir}\" /qn"; |
| 576 | 576 | ||
| 577 | var proc = Process.Start("msiexec.exe", args); | 577 | var proc = Process.Start("msiexec.exe", args); |
| 578 | proc.WaitForExit(5000); | 578 | proc.WaitForExit(10000); |
| 579 | 579 | ||
| 580 | Assert.Equal(0, proc.ExitCode); | 580 | Assert.Equal(0, proc.ExitCode); |
| 581 | } | 581 | } |
