ProcessAliases.

StartProcess(ICakeContext, FilePath, ProcessSettings, IEnumerable<string>) Method

Summary

Starts the process resource that is specified by the filename and settings.
Namespace
Cake.Common
Containing Type
ProcessAliases

Syntax

[CakeMethodAlias]
public static int StartProcess(this ICakeContext context, FilePath fileName, ProcessSettings settings, out IEnumerable<string> redirectedStandardOutput)

Examples

 IEnumerable<string> redirectedStandardOutput;
 var exitCodeWithArgument =
     StartProcess(
         "ping",
         new ProcessSettings {
             Arguments = "localhost",
             RedirectStandardOutput = true
         },
         out redirectedStandardOutput
     );

 // Output last line of process output.
 Information("Last line of output: {0}", redirectedStandardOutput.LastOrDefault());

 // This should output 0 as valid arguments supplied
 Information("Exit code: {0}", exitCodeWithArgument);

Attributes

Type Description
CakeMethodAliasAttribute An attribute used to mark script method aliases.

Parameters

Name Type Description
context ICakeContext The context.
fileName FilePath Name of the file.
settings ProcessSettings The settings.
redirectedStandardOutput IEnumerable<string> Returns process output if RedirectStandardOutput is true. Otherwise null is returned.

Return Value

Type Description
int The exit code that the started process specified when it terminated.