Process

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.

ProcessList
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

getRedirectOutputToTrace ()
Signature: unit -> bool
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

ProcessEncoding
Signature: Encoding

If AlwaysSetProcessEncoding is set to false (default) only mono processes will be changed.

setEnableProcessTracing
Signature: bool -> unit
setKillCreatedProcesses
Signature: bool -> unit
setRedirectOutputToTrace
Signature: bool -> unit
shouldEnableProcessTracing ()
Signature: unit -> bool
shouldKillCreatedProcesses ()
Signature: unit -> bool
StartProcess configProcessStartInfoF
Signature: configProcessStartInfoF:(ProcessStartInfo -> unit) -> unit

Starts the given process and forgets about it.

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
tryFindTool envVar tool
Signature: envVar:string -> tool:string -> string option

Tries to find the tool via Env-Var. If no path has the right tool we are trying the PATH system variable.