Skip to content

Commit

Permalink
Merge pull request #1752 from AArnott/fixCreateShortcut
Browse files Browse the repository at this point in the history
Fix `CreateShortcutForThisExe` for .NET Core apps
  • Loading branch information
anaisbetts authored Oct 5, 2021
2 parents 116907a + 1c610dc commit 136db8c
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/Squirrel/IUpdateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,17 @@ await This.ErrorIfThrows(() =>

public static void CreateShortcutForThisExe(this IUpdateManager This)
{
This.CreateShortcutsForExecutable(Path.GetFileName(
Assembly.GetEntryAssembly().Location),
string entrypoint = Assembly.GetEntryAssembly().Location;
if (String.Equals(Path.GetExtension(entrypoint), ".dll", StringComparison.OrdinalIgnoreCase)) {
// This happens in .NET Core apps. A shortcut to a .dll doesn't work, so replace with the .exe.
string candidateExe = Path.Combine(Path.GetDirectoryName(entrypoint), Path.GetFileNameWithoutExtension(entrypoint)) + ".exe";
if (File.Exists(candidateExe)) {
entrypoint = candidateExe;
}
}

This.CreateShortcutsForExecutable(
Path.GetFileName(entrypoint),
ShortcutLocation.Desktop | ShortcutLocation.StartMenu,
Environment.CommandLine.Contains("squirrel-install") == false,
null, null);
Expand Down

0 comments on commit 136db8c

Please sign in to comment.