Note: This API documentation is for FAKE version 4. The migration API documentation can be found here. The API documentation for the new fake 5 modules can be found here

ProcessHelper

Contains functions which can be used to start other tools.

Nested types and modules

TypeDescription
ConsoleMessage

A record type which captures console messages

ExecParams

Parameter type for process execution.

ProcessResult

A process result including error code, message log and errors.

Shell

Allows to exec shell operations synchronously and asynchronously.

Functions and values

Function or valueDescription
AlwaysSetProcessEncoding
Signature: bool

If set to true the ProcessHelper will start all processes with a custom ProcessEncoding. If set to false (default) only mono processes will be changed.

asyncShellExec(args)
Signature: args:ExecParams -> Async<int>

Execute an external program asynchronously and return the exit code, logging output and error messages to FAKE output. You can compose the result with Async.Parallel to run multiple external programs at once, but be sure that none of them depend on the output of another.

defaultParams
Signature: ExecParams

Default parameters for process execution.

directExec(configProcessStartInfoF)
Signature: configProcessStartInfoF:(ProcessStartInfo -> unit) -> bool

Runs the given process, waits for its completion and returns if it succeeded.

ensureProcessesHaveStopped name timeout
Signature: name:string -> timeout:TimeSpan -> unit

Waits until the processes with the given name have stopped or fails after given timeout.

Parameters

  • name - The name of the processes in question.
  • timeout - The timespan to time out after.
ExecProcess(...)
Signature: configProcessStartInfoF:(ProcessStartInfo -> unit) -> timeOut:TimeSpan -> int

Runs the given process and returns the exit code.

Parameters

  • configProcessStartInfoF - A function which overwrites the default ProcessStartInfo.

  • timeOut - The timeout for the process.

    Sample

    let result = ExecProcess (fun info -> info.FileName <- "c:/MyProc.exe" info.WorkingDirectory <- "c:/workingDirectory" info.Arguments <- "-v") (TimeSpan.FromMinutes 5.0)

    if result <> 0 then failwithf "MyProc.exe returned with a non-zero exit code"

ExecProcessAndReturnMessages(...)
Signature: configProcessStartInfoF:(ProcessStartInfo -> unit) -> timeOut:TimeSpan -> ProcessResult

Runs the given process and returns the process result.

Parameters

  • configProcessStartInfoF - A function which overwrites the default ProcessStartInfo.
  • timeOut - The timeout for the process.
ExecProcessElevated cmd args timeOut
Signature: cmd:string -> args:string -> timeOut:TimeSpan -> int

Runs the given process in an elevated context and returns the exit code.

Parameters

  • cmd - The command which should be run in elavated context.
  • args - The process arguments.
  • timeOut - The timeout for the process.
ExecProcessRedirected(...)
Signature: configProcessStartInfoF:(ProcessStartInfo -> unit) -> timeOut:TimeSpan -> bool * seq<ConsoleMessage>

Runs the given process and returns the process result.

Parameters

  • configProcessStartInfoF - A function which overwrites the default ProcessStartInfo.
  • timeOut - The timeout for the process.
ExecProcessWithLambdas(...)
Signature: configProcessStartInfoF:(ProcessStartInfo -> unit) -> timeOut:TimeSpan -> silent:bool -> errorF:(string -> unit) -> messageF:(string -> unit) -> int

Runs the given process and returns the exit code.

Parameters

  • configProcessStartInfoF - A function which overwrites the default ProcessStartInfo.
  • timeOut - The timeout for the process.
  • silent - If this flag is set then the process output is redirected to the given output functions errorF and messageF.
  • errorF - A function which will be called with the error log.
  • messageF - A function which will be called with the message log.
fireAndForget(configProcessStartInfoF)
Signature: configProcessStartInfoF:(ProcessStartInfo -> unit) -> unit

Starts the given process and returns immediatly.

getProcessesByName(name)
Signature: name:string -> seq<Process>

Returns all processes with the given name

kill(proc)
Signature: proc:Process -> unit

Kills the given process

killAllCreatedProcesses()
Signature: unit -> unit

Kills all processes that are created by the FAKE build script unless "donotkill" flag was set.

killFSI()
Signature: unit -> unit

Kills the F# Interactive (FSI) process.

killMSBuild()
Signature: unit -> unit

Kills the MSBuild process.

killProcess(name)
Signature: name:string -> unit

Kills all processes with the given name

killProcessById(id)
Signature: id:int -> unit

Kills all processes with the given id

pathDirectories
Signature: seq<string>

Gets the list of valid directories included in the PATH environment variable.

ProcessEncoding
Signature: Encoding

The ProcessHelper will start all processes with this encoding if AlwaysSetProcessEncoding is set to true. If AlwaysSetProcessEncoding is set to false (default) only mono processes will be changed.

RunRemoteService(...)
Signature: command:string -> host:string -> serviceName:string -> unit

Sends a command to a remote windows service.

RunService command serviceName
Signature: command:string -> serviceName:string -> unit

Sends a command to a local windows service.

StartProcess(configProcessStartInfoF)
Signature: configProcessStartInfoF:(ProcessStartInfo -> unit) -> unit

Starts the given process and forgets about it.

StartRemoteService host serviceName
Signature: host:string -> serviceName:string -> unit

Starts a remote windows service. Waits up to two minutes for a response.

StartService(serviceName)
Signature: serviceName:string -> unit

Starts a local windows service. Waits up to two minutes for a response.

StopRemoteService host serviceName
Signature: host:string -> serviceName:string -> unit

Stops a remote windows service. Waits up to two minutes for a response.

StopService(serviceName)
Signature: serviceName:string -> unit

Stops a local windows service. Waits up to two minutes for a response.

tryFindFileOnPath(file)
Signature: file:string -> string option

Searches the current directory and the directories within the PATH environment variable for the given file. If successful returns the full path to the file.

Parameters

  • file - The file to locate