10 internal async ValueTask<ExternalSolverProcessResult>
RunAsync(
11 string executablePath,
12 IEnumerable<string> arguments,
13 string workingDirectory,
14 string? standardInput,
15 CancellationToken cancellationToken)
17 ArgumentException.ThrowIfNullOrWhiteSpace(
20 ArgumentNullException.ThrowIfNull(arguments);
25 FileName = executablePath,
27 string.IsNullOrWhiteSpace(workingDirectory)
28 ? Environment.CurrentDirectory
30 UseShellExecute =
false,
31 RedirectStandardOutput =
true,
32 RedirectStandardError =
true,
33 RedirectStandardInput =
34 standardInput is not
null,
38 foreach (
string argument
in arguments)
40 startInfo.ArgumentList.Add(argument);
46 StartInfo = startInfo,
47 EnableRaisingEvents =
true
52 throw new InvalidOperationException(
53 $
"Unable to start solver executable '{executablePath}'.");
56 Task<string> stdoutTask =
57 process.StandardOutput.ReadToEndAsync(
60 Task<string> stderrTask =
61 process.StandardError.ReadToEndAsync(
64 if (standardInput is not
null)
66 await process.StandardInput.WriteAsync(
69 process.StandardInput.Close();
74 await process.WaitForExitAsync(
77 catch (OperationCanceledException)