Fix decompiling non-advertised shortcuts.
Sean Hall committed
Nov 25, 2019 at 15:22 UTC
c41ab103681b6bfdfc4c51333bca133482207abb
2 files changed
+36
-28
src/WixToolset.Core.WindowsInstaller/Decompile/Decompiler.cs
+35
-27
@@ -783,6 +783,7 @@ namespace WixToolset.Core.WindowsInstaller
783
this.FinalizePropertyTable(tables);
784
this.FinalizeRemoveFileTable(tables);
785
this.FinalizeSearchTables(tables);
786
+ this.FinalizeShortcutTable(tables);
787
this.FinalizeUpgradeTable(tables);
788
this.FinalizeSequenceTables(tables);
789
this.FinalizeVerbTable(tables);
@@ -1360,7 +1361,6 @@ namespace WixToolset.Core.WindowsInstaller
1361
var extensionTable = tables["Extension"];
1362
var msiAssemblyTable = tables["MsiAssembly"];
1363
var publishComponentTable = tables["PublishComponent"];
1363
- var shortcutTable = tables["Shortcut"];
1364
var typeLibTable = tables["TypeLib"];
1365
1366
if (null != classTable)
@@ -1395,19 +1395,6 @@ namespace WixToolset.Core.WindowsInstaller
1395
}
1396
}
1397
1398
- if (null != shortcutTable)
1399
- {
1400
- foreach (var row in shortcutTable.Rows)
1401
- {
1402
- var target = Convert.ToString(row[4]);
1403
-
1404
- if (!target.StartsWith("[", StringComparison.Ordinal) && !target.EndsWith("]", StringComparison.Ordinal))
1405
- {
1406
- this.SetPrimaryFeature(row, 4, 3);
1407
- }
1408
- }
1409
- }
1410
-
1398
if (null != typeLibTable)
1399
{
1400
foreach (var row in typeLibTable.Rows)
@@ -2434,6 +2421,40 @@ namespace WixToolset.Core.WindowsInstaller
2421
}
2422
}
2423
2424
+ /// <summary>
2425
+ /// Finalize the Shortcut table.
2426
+ /// </summary>
2427
+ /// <param name="tables">The collection of all tables.</param>
2428
+ /// <remarks>
2429
+ /// Sets Advertise to yes if Target points to a Feature.
2430
+ /// Occurs during finalization because it has to check against every feature row.
2431
+ /// </remarks>
2432
+ private void FinalizeShortcutTable(TableIndexedCollection tables)
2433
+ {
2434
+ var shortcutTable = tables["Shortcut"];
2435
+ if (null == shortcutTable)
2436
+ {
2437
+ return;
2438
+ }
2439
+
2440
+ foreach (var row in shortcutTable.Rows)
2441
+ {
2442
+ var shortcut = (Wix.Shortcut)this.core.GetIndexedElement(row);
2443
+ var target = Convert.ToString(row[4]);
2444
+ var feature = this.core.GetIndexedElement("Feature", target);
2445
+ if (feature == null)
2446
+ {
2447
+ // TODO: use this value to do a "more-correct" nesting under the indicated File or CreateDirectory element
2448
+ shortcut.Target = target;
2449
+ }
2450
+ else
2451
+ {
2452
+ shortcut.Advertise = Wix.YesNoType.yes;
2453
+ this.SetPrimaryFeature(row, 4, 3);
2454
+ }
2455
+ }
2456
+ }
2457
+
2458
/// <summary>
2459
/// Finalize the sequence tables.
2460
/// </summary>
@@ -8441,19 +8462,6 @@ namespace WixToolset.Core.WindowsInstaller
8462
shortcut.Name = names[0];
8463
}
8464
8444
- var target = Convert.ToString(row[4]);
8445
- if (target.StartsWith("[", StringComparison.Ordinal) && target.EndsWith("]", StringComparison.Ordinal))
8446
- {
8447
- // TODO: use this value to do a "more-correct" nesting under the indicated File or CreateDirectory element
8448
- shortcut.Target = target;
8449
- }
8450
- else
8451
- {
8452
- shortcut.Advertise = Wix.YesNoType.yes;
8453
-
8454
- // primary feature is set in FinalizeFeatureComponentsTable
8455
- }
8456
-
8465
if (null != row[5])
8466
{
8467
shortcut.Arguments = Convert.ToString(row[5]);
src/test/WixToolsetTest.CoreIntegration/DecompileFixture.cs
+1
-1
@@ -153,7 +153,7 @@ namespace WixToolsetTest.CoreIntegration
153
}
154
}
155
156
- [Fact(Skip = "Test demonstrates failure")]
156
+ [Fact]
157
public void CanDecompileShortcuts()
158
{
159
var folder = TestData.Get(@"TestData\Shortcut");