Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions src/Services/SimulationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,15 @@ public async Task<SimulationResult> RunAsync(
// 5. Run client
Log("STEP 5: Running Client.exe", progress);
var clientExe = Path.Combine(config.OutputDirectory, "Client.exe");
var clientArgs = $"--server-url {_server.BaseUrl} --install-path \"{config.AppDirectory}\" --current-version {config.CurrentVersion} --app-secret {config.AppSecretKey} --product-id {config.ProductId} --app-name Upgrade.exe";
var clientArgs = new List<string>
{
"--server-url", _server.BaseUrl,
"--install-path", config.AppDirectory,
"--current-version", config.CurrentVersion,
"--app-secret", config.AppSecretKey,
"--product-id", config.ProductId,
"--app-name", "Upgrade.exe"
};
var clientResult = await RunExe(clientExe, clientArgs, ct);
Log(clientResult.Output, progress);

Expand Down Expand Up @@ -163,14 +171,16 @@ private void Validate(SimulateConfigModel config)
catch { throw new InvalidOperationException("dotnet CLI not found"); }
}

private async Task<(bool Success, string Output)> RunExe(string exePath, string arguments, CancellationToken ct)
private async Task<(bool Success, string Output)> RunExe(string exePath, List<string> arguments, CancellationToken ct)
{
var psi = new ProcessStartInfo(exePath, arguments)
var psi = new ProcessStartInfo(exePath)
{
RedirectStandardOutput = true, RedirectStandardError = true,
StandardOutputEncoding = Encoding.UTF8, StandardErrorEncoding = Encoding.UTF8,
UseShellExecute = false, CreateNoWindow = true
};
foreach (var arg in arguments)
psi.ArgumentList.Add(arg);
using var p = Process.Start(psi)!;
var output = new StringBuilder();
var readTask = Task.Run(async () => { while (!p.StandardOutput.EndOfStream) output.AppendLine(await p.StandardOutput.ReadLineAsync(ct)); }, ct);
Expand Down
Loading