diff --git a/src/Faithlife.Build/AppRunner.cs b/src/Faithlife.Build/AppRunner.cs index 1d74297..2f58e06 100644 --- a/src/Faithlife.Build/AppRunner.cs +++ b/src/Faithlife.Build/AppRunner.cs @@ -126,6 +126,7 @@ private static int DoRunApp(string path, AppRunnerSettings settings) var handleOutputLine = settings.HandleOutputLine; var handleErrorLine = settings.HandleErrorLine; + var inputStream = settings.InputStream; var startInfo = new ProcessStartInfo { @@ -135,6 +136,7 @@ private static int DoRunApp(string path, AppRunnerSettings settings) UseShellExecute = false, RedirectStandardOutput = handleOutputLine is not null, RedirectStandardError = handleErrorLine is not null, + RedirectStandardInput = inputStream is not null, CreateNoWindow = false, }; @@ -180,6 +182,14 @@ private static int DoRunApp(string path, AppRunnerSettings settings) process.Start(); + if (inputStream is not null) + { + using var reader = new StreamReader(inputStream); + + process.StandardInput.Write(reader.ReadToEnd()); + process.StandardInput.Close(); + } + if (handleOutputLine is not null) process.BeginOutputReadLine(); diff --git a/src/Faithlife.Build/AppRunnerSettings.cs b/src/Faithlife.Build/AppRunnerSettings.cs index d7d576e..04144bb 100644 --- a/src/Faithlife.Build/AppRunnerSettings.cs +++ b/src/Faithlife.Build/AppRunnerSettings.cs @@ -50,6 +50,11 @@ public sealed class AppRunnerSettings /// public Action? HandleErrorLine { get; set; } + /// + /// If set, redirects standard in and uses this stream as input. + /// + public Stream? InputStream { get; set; } + /// /// Clones the settings. ///