From 86269827bc551161720e296dc2d2cad1080334cd Mon Sep 17 00:00:00 2001 From: Caelan Sayler Date: Mon, 26 May 2025 22:31:03 +0100 Subject: [PATCH] Fix MSI start-menu shortcuts --- .../Commands/WindowsPackCommandRunner.cs | 7 ++-- .../Msi/MsiBuilder.cs | 1 + .../Msi/MsiTemplateData.cs | 6 ++- .../Msi/Templates/MsiTemplate.hbs | 41 +++++++++++++++---- 4 files changed, 43 insertions(+), 12 deletions(-) diff --git a/src/vpk/Velopack.Packaging.Windows/Commands/WindowsPackCommandRunner.cs b/src/vpk/Velopack.Packaging.Windows/Commands/WindowsPackCommandRunner.cs index 4728d4d5..cf6ce904 100644 --- a/src/vpk/Velopack.Packaging.Windows/Commands/WindowsPackCommandRunner.cs +++ b/src/vpk/Velopack.Packaging.Windows/Commands/WindowsPackCommandRunner.cs @@ -90,9 +90,6 @@ public class WindowsPackCommandRunner : PackageBuilder protected string GetShortcutLocations() { - if (String.IsNullOrWhiteSpace(Options.Shortcuts)) - return "None"; - var flags = GetShortcuts(); var names = Enum.GetValues(typeof(ShortcutLocation)) .Cast() @@ -100,7 +97,9 @@ public class WindowsPackCommandRunner : PackageBuilder .Select(f => f.ToString()) .ToList(); - return names.Count > 0 ? string.Join(",", names) : "None"; + var shortcutStr = names.Count > 0 ? string.Join(",", names) : "None"; + Log.Info($"Shortcuts: {shortcutStr}"); + return shortcutStr; } protected string GetRuntimeDependencies() diff --git a/src/vpk/Velopack.Packaging.Windows/Msi/MsiBuilder.cs b/src/vpk/Velopack.Packaging.Windows/Msi/MsiBuilder.cs index 483fbddb..dd67966a 100644 --- a/src/vpk/Velopack.Packaging.Windows/Msi/MsiBuilder.cs +++ b/src/vpk/Velopack.Packaging.Windows/Msi/MsiBuilder.cs @@ -68,6 +68,7 @@ public static class MsiBuilder StubFileName = (options.PackTitle ?? options.PackId) + ".exe", DesktopShortcut = shortcuts.HasFlag(ShortcutLocation.Desktop), StartMenuShortcut = shortcuts.HasFlag(ShortcutLocation.StartMenu), + StartMenuRootShortcut = shortcuts.HasFlag(ShortcutLocation.StartMenuRoot), RustNativeModulePath = HelperFile.GetWixNativeModulePath(options.TargetRuntime), SideBannerImagePath = options.MsiBanner ?? HelperFile.WixAssetsDialogBackground, TopBannerImagePath = options.MsiLogo ?? HelperFile.WixAssetsTopBanner, diff --git a/src/vpk/Velopack.Packaging.Windows/Msi/MsiTemplateData.cs b/src/vpk/Velopack.Packaging.Windows/Msi/MsiTemplateData.cs index 711c28b0..8630e507 100644 --- a/src/vpk/Velopack.Packaging.Windows/Msi/MsiTemplateData.cs +++ b/src/vpk/Velopack.Packaging.Windows/Msi/MsiTemplateData.cs @@ -24,10 +24,14 @@ public class MsiTemplateData public string AppVersion; public string StubFileName; - public string RuntimeDependencies; public bool DesktopShortcut; public bool StartMenuShortcut; + public bool StartMenuRootShortcut; + public string RuntimeDependencies; + public bool HasRuntimeDependencies => !string.IsNullOrWhiteSpace(RuntimeDependencies); + + public bool InstallLocationEither => InstallForAllUsers && InstallForCurrentUser; public bool InstallLocationAllUsersOnly => InstallForAllUsers && !InstallForCurrentUser; public bool InstallLocationCurrentUserOnly => !InstallForAllUsers && InstallForCurrentUser; diff --git a/src/vpk/Velopack.Packaging.Windows/Msi/Templates/MsiTemplate.hbs b/src/vpk/Velopack.Packaging.Windows/Msi/Templates/MsiTemplate.hbs index 0604b59f..54d7542b 100644 --- a/src/vpk/Velopack.Packaging.Windows/Msi/Templates/MsiTemplate.hbs +++ b/src/vpk/Velopack.Packaging.Windows/Msi/Templates/MsiTemplate.hbs @@ -29,15 +29,40 @@ {{/if}} {{#if StartMenuShortcut}} - + + + + + - - - + + + + + {{/if}} + + {{#if StartMenuRootShortcut}} + + + + + + {{/if}} {{#if HasIcon}} @@ -90,7 +115,9 @@ - + {{#if HasRuntimeDependencies}} + + {{/if}} @@ -104,7 +131,7 @@ Return="ignore"/> - +