From e844f12f7d7247a1e9ba4eef2a388e614001bb24 Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Tue, 29 Jun 2021 15:49:49 -0400 Subject: Fix decompilation for TARGETDIR-rooted components. Also ensure modularization Guid is decompiled. --- .../Decompile/Decompiler.cs | 10 +++++++++- .../DecompileFixture.cs | 4 ++-- .../DecompileTargetDirMergeModule/Expected.wxs | 17 +++++++++++------ .../DecompileTargetDirMergeModule/MergeModule1.msm | Bin 32768 -> 32768 bytes 4 files changed, 22 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/wix/WixToolset.Core.WindowsInstaller/Decompile/Decompiler.cs b/src/wix/WixToolset.Core.WindowsInstaller/Decompile/Decompiler.cs index 0b45a8b3..9c338293 100644 --- a/src/wix/WixToolset.Core.WindowsInstaller/Decompile/Decompiler.cs +++ b/src/wix/WixToolset.Core.WindowsInstaller/Decompile/Decompiler.cs @@ -767,6 +767,13 @@ namespace WixToolset.Core.WindowsInstaller.Decompile // set the component keypaths if (null != componentTable) { + // Add the TARGETDIR StandardDirectory if a component is directly parented there. + if (componentTable.Rows.Any(row => row.FieldAsString(2) == "TARGETDIR") + && this.TryGetIndexedElement("Directory", out var xDirectory, "TARGETDIR")) + { + this.RootElement.Add(xDirectory); + } + foreach (var row in componentTable.Rows) { var attributes = row.FieldAsInteger(3); @@ -2449,6 +2456,7 @@ namespace WixToolset.Core.WindowsInstaller.Decompile var table = tables["_SummaryInformation"]; var row = table.Rows.SingleOrDefault(r => r.FieldAsInteger(0) == 9); this.ModularizationGuid = row?.FieldAsString(1); + this.RootElement.SetAttributeValue("Guid", this.ModularizationGuid); } // index the rows from the extension libraries @@ -4352,7 +4360,7 @@ namespace WixToolset.Core.WindowsInstaller.Decompile if (id == "TARGETDIR") { - // Skip TARGETDIR (but see below!). + // Skip TARGETDIR -- but it will be added for any components directly targeted. } else if (row.IsColumnNull(1) || WindowsInstallerStandard.IsStandardDirectory(id)) { diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/DecompileFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/DecompileFixture.cs index ab04da15..e87bbfee 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/DecompileFixture.cs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/DecompileFixture.cs @@ -24,9 +24,9 @@ namespace WixToolsetTest.CoreIntegration Path.Combine(folder, msiName), "-intermediateFolder", intermediateFolder, "-o", outputPath - }); + }, out var messages); - result.AssertSuccess(); + Assert.Equal(0, result); WixAssert.CompareXml(Path.Combine(folder, expectedWxsName), outputPath); } diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/DecompileTargetDirMergeModule/Expected.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/DecompileTargetDirMergeModule/Expected.wxs index 7c5fe3cf..4a89f56b 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/DecompileTargetDirMergeModule/Expected.wxs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/DecompileTargetDirMergeModule/Expected.wxs @@ -1,11 +1,6 @@  - - - - - - + @@ -13,6 +8,16 @@ + + + + + + + + + + \ No newline at end of file diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/DecompileTargetDirMergeModule/MergeModule1.msm b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/DecompileTargetDirMergeModule/MergeModule1.msm index 2a7b5e3a..a09cab20 100644 Binary files a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/DecompileTargetDirMergeModule/MergeModule1.msm and b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/DecompileTargetDirMergeModule/MergeModule1.msm differ -- cgit v1.2.3-55-g6feb