From 7796d0bee6dd092fb1c3a3d15c77e5a5f7e68e44 Mon Sep 17 00:00:00 2001 From: Ravi Patel Date: Sat, 29 Apr 2023 10:38:10 +0530 Subject: [PATCH] Now using extracted method to build arguments for msi installer too. --- AutoUpdater.NET/DownloadUpdateDialog.cs | 47 +++++-------------------- 1 file changed, 9 insertions(+), 38 deletions(-) diff --git a/AutoUpdater.NET/DownloadUpdateDialog.cs b/AutoUpdater.NET/DownloadUpdateDialog.cs index 226d243..5e4da9a 100644 --- a/AutoUpdater.NET/DownloadUpdateDialog.cs +++ b/AutoUpdater.NET/DownloadUpdateDialog.cs @@ -186,7 +186,6 @@ private void WebClientOnDownloadFileCompleted(object sender, AsyncCompletedEvent UseShellExecute = true }; -#if NETFRAMEWORK var arguments = new Collection { "--input", @@ -216,33 +215,6 @@ private void WebClientOnDownloadFileCompleted(object sender, AsyncCompletedEvent } processStartInfo.Arguments = Utils.BuildArguments(arguments); -#else - processStartInfo.ArgumentList.Add("--input"); - processStartInfo.ArgumentList.Add(tempPath); - processStartInfo.ArgumentList.Add("--output"); - processStartInfo.ArgumentList.Add(extractionPath); - processStartInfo.ArgumentList.Add("--current-exe"); - processStartInfo.ArgumentList.Add(currentExe); - - if (!string.IsNullOrWhiteSpace(updatedExe)) - { - processStartInfo.ArgumentList.Add("--updated-exe"); - processStartInfo.ArgumentList.Add(updatedExe); - } - - if (AutoUpdater.ClearAppDirectory) - { - processStartInfo.ArgumentList.Add("--clear"); - } - - string[] args = Environment.GetCommandLineArgs(); - if (args.Length > 0) - { - string arguments = string.Join(" ", args.Skip(1).Select(arg => $"\"{arg}\"")); - processStartInfo.ArgumentList.Add("--args"); - processStartInfo.ArgumentList.Add(arguments); - } -#endif } else if (extension.Equals(".msi", StringComparison.OrdinalIgnoreCase)) { @@ -250,20 +222,19 @@ private void WebClientOnDownloadFileCompleted(object sender, AsyncCompletedEvent { FileName = "msiexec" }; -#if NETFRAMEWORK - processStartInfo.Arguments = $"/i \"{tempPath}\""; - if (!string.IsNullOrEmpty(installerArgs)) + + var arguments = new Collection { - processStartInfo.Arguments += $" {installerArgs}"; - } -#else - processStartInfo.ArgumentList.Add("/i"); - processStartInfo.ArgumentList.Add(tempPath); + "/i", + tempPath + }; + if (!string.IsNullOrEmpty(installerArgs)) { - processStartInfo.ArgumentList.Add(installerArgs); + arguments.Add(installerArgs); } -#endif + + processStartInfo.Arguments = Utils.BuildArguments(arguments); } if (AutoUpdater.RunUpdateAsAdmin)