Skip to content

Commit

Permalink
Fix CreateShortcutForThisExe for .NET Core apps
Browse files Browse the repository at this point in the history
The entrypoint assembly is reported as being a .dll in the .NET Core case. A shortcut to the dll is *not* what the developer expects and it doesn't work for the user. Instead, look for a nearby .exe with the same file name and use that.
  • Loading branch information
AArnott committed Oct 4, 2021
1 parent d854131 commit 1c610dc
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 1c610dc

Please sign in to comment.