From 3f4bd928ab4c048792bf4c5c10004a1f22e8aa19 Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Mon, 12 Apr 2021 15:13:08 -0400 Subject: Fix decompilation of directories as children TARGETDIR. --- .../Decompile/Decompiler.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src/WixToolset.Core.WindowsInstaller') diff --git a/src/WixToolset.Core.WindowsInstaller/Decompile/Decompiler.cs b/src/WixToolset.Core.WindowsInstaller/Decompile/Decompiler.cs index eb23f497..0b45a8b3 100644 --- a/src/WixToolset.Core.WindowsInstaller/Decompile/Decompiler.cs +++ b/src/WixToolset.Core.WindowsInstaller/Decompile/Decompiler.cs @@ -4352,7 +4352,7 @@ namespace WixToolset.Core.WindowsInstaller.Decompile if (id == "TARGETDIR") { - // Skip TARGETDIR. + // Skip TARGETDIR (but see below!). } else if (row.IsColumnNull(1) || WindowsInstallerStandard.IsStandardDirectory(id)) { @@ -4360,7 +4360,9 @@ namespace WixToolset.Core.WindowsInstaller.Decompile } else { - if (!this.TryGetIndexedElement("Directory", out var xParentDirectory, row.FieldAsString(1))) + var parentDirectoryId = row.FieldAsString(1); + + if (!this.TryGetIndexedElement("Directory", out var xParentDirectory, parentDirectoryId)) { this.Messaging.Write(WarningMessages.ExpectedForeignRow(row.SourceLineNumbers, table.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "Directory_Parent", row.FieldAsString(1), "Directory")); } @@ -4370,7 +4372,15 @@ namespace WixToolset.Core.WindowsInstaller.Decompile } else { - xParentDirectory.Add(xDirectory); + // TARGETDIR is omitted but if this directory is a first-generation descendant, add it as a root. + if (parentDirectoryId == "TARGETDIR") + { + this.RootElement.Add(xDirectory); + } + else + { + xParentDirectory.Add(xDirectory); + } } } } -- cgit v1.2.3-55-g6feb