Skip to content

Commit

Permalink
Now using extracted method to build arguments for msi installer too.
Browse files Browse the repository at this point in the history
  • Loading branch information
ravibpatel committed Apr 29, 2023
1 parent 9632536 commit 7796d0b
Showing 1 changed file with 9 additions and 38 deletions.
47 changes: 9 additions & 38 deletions AutoUpdater.NET/DownloadUpdateDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ private void WebClientOnDownloadFileCompleted(object sender, AsyncCompletedEvent
UseShellExecute = true
};

#if NETFRAMEWORK
var arguments = new Collection<string>
{
"--input",
Expand Down Expand Up @@ -216,54 +215,26 @@ 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))
{
processStartInfo = new ProcessStartInfo
{
FileName = "msiexec"
};
#if NETFRAMEWORK
processStartInfo.Arguments = $"/i \"{tempPath}\"";
if (!string.IsNullOrEmpty(installerArgs))

var arguments = new Collection<string>
{
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)
Expand Down

0 comments on commit 7796d0b

Please sign in to comment.