Skip to content

Commit 136db8c

Browse files
authored
Merge pull request #1752 from AArnott/fixCreateShortcut
Fix `CreateShortcutForThisExe` for .NET Core apps
2 parents 116907a + 1c610dc commit 136db8c

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

src/Squirrel/IUpdateManager.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,17 @@ await This.ErrorIfThrows(() =>
183183

184184
public static void CreateShortcutForThisExe(this IUpdateManager This)
185185
{
186-
This.CreateShortcutsForExecutable(Path.GetFileName(
187-
Assembly.GetEntryAssembly().Location),
186+
string entrypoint = Assembly.GetEntryAssembly().Location;
187+
if (String.Equals(Path.GetExtension(entrypoint), ".dll", StringComparison.OrdinalIgnoreCase)) {
188+
// This happens in .NET Core apps. A shortcut to a .dll doesn't work, so replace with the .exe.
189+
string candidateExe = Path.Combine(Path.GetDirectoryName(entrypoint), Path.GetFileNameWithoutExtension(entrypoint)) + ".exe";
190+
if (File.Exists(candidateExe)) {
191+
entrypoint = candidateExe;
192+
}
193+
}
194+
195+
This.CreateShortcutsForExecutable(
196+
Path.GetFileName(entrypoint),
188197
ShortcutLocation.Desktop | ShortcutLocation.StartMenu,
189198
Environment.CommandLine.Contains("squirrel-install") == false,
190199
null, null);

0 commit comments

Comments
 (0)