From c41ab103681b6bfdfc4c51333bca133482207abb Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Mon, 25 Nov 2019 15:22:32 +1000 Subject: Fix decompiling non-advertised shortcuts. --- .../Decompile/Decompiler.cs | 62 ++++++++++++---------- 1 file changed, 35 insertions(+), 27 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 ba515d69..9ecad783 100644 --- a/src/WixToolset.Core.WindowsInstaller/Decompile/Decompiler.cs +++ b/src/WixToolset.Core.WindowsInstaller/Decompile/Decompiler.cs @@ -783,6 +783,7 @@ namespace WixToolset.Core.WindowsInstaller this.FinalizePropertyTable(tables); this.FinalizeRemoveFileTable(tables); this.FinalizeSearchTables(tables); + this.FinalizeShortcutTable(tables); this.FinalizeUpgradeTable(tables); this.FinalizeSequenceTables(tables); this.FinalizeVerbTable(tables); @@ -1360,7 +1361,6 @@ namespace WixToolset.Core.WindowsInstaller var extensionTable = tables["Extension"]; var msiAssemblyTable = tables["MsiAssembly"]; var publishComponentTable = tables["PublishComponent"]; - var shortcutTable = tables["Shortcut"]; var typeLibTable = tables["TypeLib"]; if (null != classTable) @@ -1395,19 +1395,6 @@ namespace WixToolset.Core.WindowsInstaller } } - if (null != shortcutTable) - { - foreach (var row in shortcutTable.Rows) - { - var target = Convert.ToString(row[4]); - - if (!target.StartsWith("[", StringComparison.Ordinal) && !target.EndsWith("]", StringComparison.Ordinal)) - { - this.SetPrimaryFeature(row, 4, 3); - } - } - } - if (null != typeLibTable) { foreach (var row in typeLibTable.Rows) @@ -2434,6 +2421,40 @@ namespace WixToolset.Core.WindowsInstaller } } + /// + /// Finalize the Shortcut table. + /// + /// The collection of all tables. + /// + /// Sets Advertise to yes if Target points to a Feature. + /// Occurs during finalization because it has to check against every feature row. + /// + private void FinalizeShortcutTable(TableIndexedCollection tables) + { + var shortcutTable = tables["Shortcut"]; + if (null == shortcutTable) + { + return; + } + + foreach (var row in shortcutTable.Rows) + { + var shortcut = (Wix.Shortcut)this.core.GetIndexedElement(row); + var target = Convert.ToString(row[4]); + var feature = this.core.GetIndexedElement("Feature", target); + if (feature == null) + { + // TODO: use this value to do a "more-correct" nesting under the indicated File or CreateDirectory element + shortcut.Target = target; + } + else + { + shortcut.Advertise = Wix.YesNoType.yes; + this.SetPrimaryFeature(row, 4, 3); + } + } + } + /// /// Finalize the sequence tables. /// @@ -8441,19 +8462,6 @@ namespace WixToolset.Core.WindowsInstaller shortcut.Name = names[0]; } - var target = Convert.ToString(row[4]); - if (target.StartsWith("[", StringComparison.Ordinal) && target.EndsWith("]", StringComparison.Ordinal)) - { - // TODO: use this value to do a "more-correct" nesting under the indicated File or CreateDirectory element - shortcut.Target = target; - } - else - { - shortcut.Advertise = Wix.YesNoType.yes; - - // primary feature is set in FinalizeFeatureComponentsTable - } - if (null != row[5]) { shortcut.Arguments = Convert.ToString(row[5]); -- cgit v1.2.3-55-g6feb