Fix MSI start-menu shortcuts

This commit is contained in:
Caelan Sayler
2025-05-26 22:31:03 +01:00
parent 754cea315b
commit 86269827bc
4 changed files with 43 additions and 12 deletions

View File

@@ -90,9 +90,6 @@ public class WindowsPackCommandRunner : PackageBuilder<WindowsPackOptions>
protected string GetShortcutLocations()
{
if (String.IsNullOrWhiteSpace(Options.Shortcuts))
return "None";
var flags = GetShortcuts();
var names = Enum.GetValues(typeof(ShortcutLocation))
.Cast<ShortcutLocation>()
@@ -100,7 +97,9 @@ public class WindowsPackCommandRunner : PackageBuilder<WindowsPackOptions>
.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()

View File

@@ -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,

View File

@@ -24,9 +24,13 @@ 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;

View File

@@ -29,15 +29,40 @@
{{/if}}
{{#if StartMenuShortcut}}
<StandardDirectory Id="StartMenuFolder">
<!-- Shortcut is placed in Start > Programs > AppPublisher -->
<Directory Id="ProgramMenuFolder">
<Directory Id="AppPublisherProgramMenuDir" Name="{{AppPublisherSanitized}}"/>
</Directory>
<DirectoryRef Id="AppPublisherProgramMenuDir">
<Component Id="ApplicationStartMenuShortcut">
<Shortcut Id="ApplicationStartMenuShortcut" Name="{{AppTitle}}" Description="Start Menu shortcut for {{AppTitle}}"
Target="[INSTALLFOLDER]{{StubFileName}}" WorkingDirectory="INSTALLFOLDER"/>
<RemoveFolder Id="CleanUpStartMenuShortcut" Directory="INSTALLFOLDER" On="uninstall"/>
<RegistryValue Root="HKCU" Key="Software&#92;{{AppPublisherSanitized}}&#92;{{AppId}}.StartMenuShortcut"
<Shortcut
Id="ApplicationStartMenuShortcut"
Name="{{AppTitle}}"
Description="Start Menu shortcut for {{AppTitle}}"
Target="[INSTALLFOLDER]{{StubFileName}}"
WorkingDirectory="INSTALLFOLDER"/>
<RemoveFolder Id="CleanUpStartMenuShortcut" Directory="AppPublisherProgramMenuDir" On="uninstall"/>
<RegistryValue Root="HKMU" Key="Software&#92;{{AppPublisherSanitized}}&#92;{{AppId}}.StartMenuShortcut"
Name="installed" Type="integer" Value="1" KeyPath="yes"/>
</Component>
</DirectoryRef>
{{/if}}
{{#if StartMenuRootShortcut}}
<!-- Shortcut is placed directly in Start > Programs -->
<StandardDirectory Id="ProgramMenuFolder">
<Component Id="ApplicationStartMenuRootShortcut">
<Shortcut
Id="ApplicationStartMenuRootShortcut"
Name="{{AppTitle}}"
Description="Start Menu shortcut for {{AppTitle}}"
Target="[INSTALLFOLDER]{{StubFileName}}"
WorkingDirectory="INSTALLFOLDER"/>
<RegistryValue Root="HKMU" Key="Software&#92;{{AppPublisherSanitized}}&#92;{{AppId}}.StartMenuRootShortcut"
Name="installed" Type="integer" Value="1" KeyPath="yes"/>
</Component>
</StandardDirectory>
{{/if}}
{{#if HasIcon}}
@@ -90,7 +115,9 @@
<Property Id="RustAppId" Value="{{AppTitle}}"/>
<Property Id="RustAppTitle" Value="{{AppTitle}}"/>
<Property Id="RustAppVersion" Value="{{AppVersion}}"/>
<Property Id="RustRuntimeDependencies" Value="{{RuntimeDependencies}}"/>
{{#if HasRuntimeDependencies}}
<Property Id="RustRuntimeDependencies" Value="{{RuntimeDependencies}}"/>
{{/if}}
<Property Id="RustStubFileName" Value="{{StubFileName}}"/>
<CustomAction Id="RustEarlyBootstrap" BinaryRef="RustDll" DllEntry="EarlyBootstrap" Execute="immediate" Return="check"/>
@@ -104,7 +131,7 @@
Return="ignore"/>
<InstallUISequence>
<Custom Action="RustEarlyBootstrap" Before="AppSearch" Condition="NOT REMOVE AND NOT RustRuntimeDependencies"/>
<Custom Action="RustEarlyBootstrap" Before="AppSearch" Condition="NOT REMOVE AND RustRuntimeDependencies"/>
</InstallUISequence>
<InstallExecuteSequence>