From c29608d789165a0dd43441c8918997ae18e31429 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jeremia=20M=C3=B6rling?= Date: Fri, 11 Oct 2019 09:57:56 +0200 Subject: [PATCH] Bug fix for UpdateManager.RestartApp: Getting correct exe file even when EntryAssembly is a dll. --- src/Squirrel/UpdateManager.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Squirrel/UpdateManager.cs b/src/Squirrel/UpdateManager.cs index 9f96e773e..e9d22b37f 100644 --- a/src/Squirrel/UpdateManager.cs +++ b/src/Squirrel/UpdateManager.cs @@ -187,7 +187,14 @@ public static void RestartApp(string exeToStart = null, string arguments = null) // launching a different version than we started with (this is why // we take the app's *name* rather than a full path) - exeToStart = exeToStart ?? Path.GetFileName(Assembly.GetEntryAssembly().Location); + if (exeToStart == null) + { + var exeFileFullPath = Process.GetCurrentProcess().MainModule.FileName; + // Get everything after the last backslash. + var fileNameRegex = new Regex(@"^.*\\(?[^\\]+\.exe)$"); + exeToStart = fileNameRegex.Match(exeFileFullPath).Groups["FileName"].Value; + } + var argsArg = arguments != null ? String.Format("-a \"{0}\"", arguments) : "";