@joebigelow / wix / commits / e844f12f

Fix decompilation for TARGETDIR-rooted components.

Also ensure modularization Guid is decompiled.

Bob Arnson committed Jun 29, 2021 at 15:49 UTC e844f12f7d7247a1e9ba4eef2a388e614001bb24
4 files changed +22 -9
src/wix/WixToolset.Core.WindowsInstaller/Decompile/Decompiler.cs
+9 -1
@@ -767,6 +767,13 @@ namespace WixToolset.Core.WindowsInstaller.Decompile
767 // set the component keypaths
768 if (null != componentTable)
769 {
770 + // Add the TARGETDIR StandardDirectory if a component is directly parented there.
771 + if (componentTable.Rows.Any(row => row.FieldAsString(2) == "TARGETDIR")
772 + && this.TryGetIndexedElement("Directory", out var xDirectory, "TARGETDIR"))
773 + {
774 + this.RootElement.Add(xDirectory);
775 + }
776 +
777 foreach (var row in componentTable.Rows)
778 {
779 var attributes = row.FieldAsInteger(3);
@@ -2449,6 +2456,7 @@ namespace WixToolset.Core.WindowsInstaller.Decompile
2456 var table = tables["_SummaryInformation"];
2457 var row = table.Rows.SingleOrDefault(r => r.FieldAsInteger(0) == 9);
2458 this.ModularizationGuid = row?.FieldAsString(1);
2459 + this.RootElement.SetAttributeValue("Guid", this.ModularizationGuid);
2460 }
2461
2462 // index the rows from the extension libraries
@@ -4352,7 +4360,7 @@ namespace WixToolset.Core.WindowsInstaller.Decompile
4360
4361 if (id == "TARGETDIR")
4362 {
4355 - // Skip TARGETDIR (but see below!).
4363 + // Skip TARGETDIR -- but it will be added for any components directly targeted.
4364 }
4365 else if (row.IsColumnNull(1) || WindowsInstallerStandard.IsStandardDirectory(id))
4366 {
src/wix/test/WixToolsetTest.CoreIntegration/DecompileFixture.cs
+2 -2
@@ -24,9 +24,9 @@ namespace WixToolsetTest.CoreIntegration
24 Path.Combine(folder, msiName),
25 "-intermediateFolder", intermediateFolder,
26 "-o", outputPath
27 - });
27 + }, out var messages);
28
29 - result.AssertSuccess();
29 + Assert.Equal(0, result);
30
31 WixAssert.CompareXml(Path.Combine(folder, expectedWxsName), outputPath);
32 }
src/wix/test/WixToolsetTest.CoreIntegration/TestData/DecompileTargetDirMergeModule/Expected.wxs
+11 -6
@@ -1,11 +1,6 @@
1 <?xml version="1.0" encoding="utf-8"?>
2 <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
3 - <Module Id="MergeModule1" Language="1033" Version="1.0.0.0" InstallerVersion="200">
4 - <Directory Id="MergeRedirectFolder">
5 - <Component Id="ModuleComponent2" Guid="{BB222EE8-229B-4051-9443-49E348F0CC77}" Bitness="always32">
6 - <File Id="File2" ShortName="sfmxqeab.wxs" Name="MergeModule.wxs" KeyPath="yes" Source="SourceDir\File\File2.F844F0E3_8CB4_4A0F_973E_31C4F9338382" />
7 - </Component>
8 - </Directory>
3 + <Module Codepage="65001" Id="MergeModule1" Language="1033" Version="1.0.0.0" InstallerVersion="200" Guid="{F844F0E3-8CB4-4A0F-973E-31C4F9338382}">
4 <StandardDirectory Id="ProgramFilesFolder">
5 <Directory Id="WixTestDir" ShortName="7bhhvaai" Name="WiX Toolset Test Directory">
6 <Component Id="ModuleComponent1" Guid="{D86EC5A2-9576-4699-BDC3-00586FF72CBE}" Bitness="always32">
@@ -13,6 +8,16 @@
8 </Component>
9 </Directory>
10 </StandardDirectory>
11 + <Directory Id="MergeRedirectFolder">
12 + <Component Id="ModuleComponent2" Guid="{BB222EE8-229B-4051-9443-49E348F0CC77}" Bitness="always32">
13 + <File Id="File2" ShortName="sfmxqeab.wxs" Name="MergeModule.wxs" KeyPath="yes" Source="SourceDir\File\File2.F844F0E3_8CB4_4A0F_973E_31C4F9338382" />
14 + </Component>
15 + </Directory>
16 <SummaryInformation Description="MergeModule1" Manufacturer="WiX Toolset contributors" />
17 + <StandardDirectory Id="TARGETDIR">
18 + <Component Id="ModuleComponent3" Guid="{63A2B2B1-32BE-46FF-8863-4C85A2745F62}" Bitness="always32">
19 + <RegistryValue KeyPath="yes" Id="Reg1" Root="HKLM" Key="SOFTWARE\WiX Toolset\MergeModuleDecompileTest" Name="DoesntReallyMatter" Value="Hello" Type="string" />
20 + </Component>
21 + </StandardDirectory>
22 </Module>
23 </Wix>
\ No newline at end of file
src/wix/test/WixToolsetTest.CoreIntegration/TestData/DecompileTargetDirMergeModule/MergeModule1.msm
Binary files a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/DecompileTargetDirMergeModule/MergeModule1.msm and b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/DecompileTargetDirMergeModule/MergeModule1.msm differ