[CakeMethodAlias]
publicstaticintStartProcess(this ICakeContext context, FilePath fileName, ProcessSettings settings, out IEnumerable<string> redirectedStandardOutput, out IEnumerable<string> redirectedErrorOutput)
Examples
IEnumerable<string> redirectedStandardOutput;
IEnumerable<string> redirectedErrorOutput;
var exitCodeWithArgument =
StartProcess(
"ping",
new ProcessSettings {
Arguments = "localhost",
RedirectStandardOutput = true,
RedirectStandardError = true
},
out redirectedStandardOutput,
out redirectedErrorOutput
);
// Output last line of process output.
Information("Last line of output: {0}", redirectedStandardOutput.LastOrDefault());
// Throw exception if anything was written to the standard error.if (redirectedErrorOutput.Any())
{
thrownew Exception(
string.Format(
"Errors occurred: {0}",
string.Join(", ", redirectedErrorOutput)));
}
// This should output 0 as valid arguments supplied
Information("Exit code: {0}", exitCodeWithArgument);