FAKE - F# Make - A DSL for build tasks and more FAKE
6.1.3

Lookig for older versions of the documentation, pre FAKE v6? See 

v5.fake.build

CreateProcess Module

Module for creating and modifying CreateProcess<'TRes> instances.

You can manage:

  • The command (ie file to execute and arguments)
  • The working directory
  • The process environment
  • Stream redirection and pipes
  • Timeout for the process to exit
  • The result and the result transformations (map, mapResult)

More extensions can be found in the CreateProcess Extensions

Example


 Command.RawCommand("file", Arguments.OfArgs ["arg1"; "arg2"])
     |> CreateProcess.fromCommand
     |> Proc.run
     |> ignore

Functions and values

Function or value Description

addOnExited f c

Full Usage: addOnExited f c

Parameters:
    f : 'a -> int -> 'b - Function to add on exit event
    c : CreateProcess<'a> - The create process instance

Returns: CreateProcess<'b>

Execute the given function after the process has been exited and the previous result has been calculated.

f : 'a -> int -> 'b

Function to add on exit event

c : CreateProcess<'a>

The create process instance

Returns: CreateProcess<'b>

addOnFinally f c

Full Usage: addOnFinally f c

Parameters:
    f : unit -> unit - Function to add as a finally clause
    c : CreateProcess<'a> - The create process instance

Returns: CreateProcess<'a>

Execute the given function when the process is cleaned up.

f : unit -> unit

Function to add as a finally clause

c : CreateProcess<'a>

The create process instance

Returns: CreateProcess<'a>

addOnSetup f c

Full Usage: addOnSetup f c

Parameters:
    f : unit -> 'a - Function to add on setup
    c : CreateProcess<'b> - The create process instance

Returns: CreateProcess<'b>

Execute the given function before the process is started

f : unit -> 'a

Function to add on setup

c : CreateProcess<'b>

The create process instance

Returns: CreateProcess<'b>

addOnStarted f c

Full Usage: addOnStarted f c

Parameters:
    f : unit -> unit - Function to add on started event
    c : CreateProcess<'a> - The create process instance

Returns: CreateProcess<'a>

Execute the given function right after the process is started.

f : unit -> unit

Function to add on started event

c : CreateProcess<'a>

The create process instance

Returns: CreateProcess<'a>

addOnStartedEx f c

Full Usage: addOnStartedEx f c

Parameters:
Returns: CreateProcess<'a>

Execute the given function right after the process is started. PID for process can be obtained from p parameter (p.Process.Id).

f : StartedProcessInfo -> unit

Function to add on started event

c : CreateProcess<'a>

The create process instance

Returns: CreateProcess<'a>

appendSimpleFuncs prepareState onStart onResult onDispose c

Full Usage: appendSimpleFuncs prepareState onStart onResult onDispose c

Parameters:
    prepareState : unit -> 'a - Function to override state
    onStart : 'a -> Process -> unit - Function to override start
    onResult : Async<'b> -> 'a -> Task<RawProcessResult> -> Async<'c> - Function to override result
    onDispose : 'a -> unit - Function to override dispose
    c : CreateProcess<'b> - The create process instance

Returns: CreateProcess<'c>

Attaches the given functions to the current CreateProcess instance.

prepareState : unit -> 'a

Function to override state

onStart : 'a -> Process -> unit

Function to override start

onResult : Async<'b> -> 'a -> Task<RawProcessResult> -> Async<'c>

Function to override result

onDispose : 'a -> unit

Function to override dispose

c : CreateProcess<'b>

The create process instance

Returns: CreateProcess<'c>

copyRedirectedProcessOutputsToStandardOutputs c

Full Usage: copyRedirectedProcessOutputsToStandardOutputs c

Parameters:
    c : CreateProcess<'a> - The process to copy output to standard output

Returns: CreateProcess<'a>

Copies std-out and std-err into the corresponding System.Console streams (by using interceptStream).

c : CreateProcess<'a>

The process to copy output to standard output

Returns: CreateProcess<'a>

disableTraceCommand c

Full Usage: disableTraceCommand c

Parameters:
Returns: CreateProcess<'a>

Disable the default trace of started processes.

c : CreateProcess<'a>

The create process instance

Returns: CreateProcess<'a>

ensureExitCode r

Full Usage: ensureExitCode r

Parameters:
Returns: CreateProcess<'a>

Makes sure the exit code is 0, otherwise a detailed exception is thrown (showing the command line).

r : CreateProcess<'a>
Returns: CreateProcess<'a>

ensureExitCodeWithMessage msg r

Full Usage: ensureExitCodeWithMessage msg r

Parameters:
Returns: CreateProcess<'a>

throws an exception with the given message if exitCode <> 0

msg : string

The message to use

r : CreateProcess<'a>
Returns: CreateProcess<'a>

fromCommand command

Full Usage: fromCommand command

Parameters:
Returns: CreateProcess<ProcessResult<unit>>

Create a simple CreateProcess<_> instance from the given command.

command : Command
Returns: CreateProcess<ProcessResult<unit>>
Example


 Command.RawCommand("file", Arguments.OfArgs ["arg1"; "arg2"])
     |> CreateProcess.fromCommand
     |> Proc.run
     |> ignore

fromRawCommand command args

Full Usage: fromRawCommand command args

Parameters:
Returns: CreateProcess<ProcessResult<unit>>

Create a CreateProcess from the given file and arguments

command : FilePath
args : seq<string>
Returns: CreateProcess<ProcessResult<unit>>
Example


 CreateProcess.fromRawCommand "cmd" [ "/C";  "echo test" ]
     |> Proc.run
     |> ignore

fromRawCommandLine command windowsCommandLine

Full Usage: fromRawCommandLine command windowsCommandLine

Parameters:
    command : FilePath
    windowsCommandLine : string

Returns: CreateProcess<ProcessResult<unit>>

Create a CreateProcess from the given file and arguments

Using BlackFox.CommandLine
See BlackFox.CommandLine for details open BlackFox.CommandLine CmdLine.empty |> CmdLine.append "build" |> CmdLine.appendIf noRestore "--no-restore" |> CmdLine.appendPrefixIfSome "--framework" framework |> CmdLine.appendPrefixf "--configuration" "%A" configuration |> CmdLine.toString |> CreateProcess.fromRawCommandLine "dotnet.exe" |> Proc.run |> ignore

command : FilePath
windowsCommandLine : string
Returns: CreateProcess<ProcessResult<unit>>
Example


 CreateProcess.fromRawCommandLine "cmd" "/C \"echo test\""
     |> Proc.run
     |> ignore

getEnvironmentMap c

Full Usage: getEnvironmentMap c

Parameters:
Returns: EnvMap

Retrieve the current environment map.

c : CreateProcess<'a>

The create process instance

Returns: EnvMap

interceptStream target s

Full Usage: interceptStream target s

Parameters:
Returns: StreamSpecification

Intercept the given StreamSpecification and writes the intercepted data into target. Throws if the stream is not redirected (ie is Inherit).

target : Stream

The target stream

s : StreamSpecification

The target stream specification

Returns: StreamSpecification

map f c

Full Usage: map f c

Parameters:
Returns: CreateProcess<'b>

Map the current result to a new type.

f : 'a -> 'b
c : CreateProcess<'a>
Returns: CreateProcess<'b>

mapFilePath f c

Full Usage: mapFilePath f c

Parameters:
Returns: CreateProcess<'a>

Map the file-path according to the given function.

f : FilePath -> FilePath

Function to override file path

c : CreateProcess<'a>

The create process instance

Returns: CreateProcess<'a>

mapResult f c

Full Usage: mapResult f c

Parameters:
Returns: CreateProcess<ProcessResult<'b>>

Map only the result object and leave the exit code in the result type.

f : 'a -> 'b

Function to run result map through

c : CreateProcess<ProcessResult<'a>>
Returns: CreateProcess<ProcessResult<'b>>

ofStartInfo p

Full Usage: ofStartInfo p

Parameters:
Returns: CreateProcess<ProcessResult<unit>>

Create a CreateProcess from the given ProcessStartInfo

p : ProcessStartInfo
Returns: CreateProcess<ProcessResult<unit>>

redirectOutput c

Full Usage: redirectOutput c

Parameters:
Returns: CreateProcess<ProcessResult<ProcessOutput>>

Starts redirecting the output streams and collects all data at the end.

c : CreateProcess<'a>

The create process instance

Returns: CreateProcess<ProcessResult<ProcessOutput>>

redirectOutputIfNotRedirected c

Full Usage: redirectOutputIfNotRedirected c

Parameters:
Returns: CreateProcess<'a>

Starts redirecting the output streams if they are not already redirected. Be careful when using this function. Using redirectOutput is the preferred variant

c : CreateProcess<'a>

The create process instance

Returns: CreateProcess<'a>

replaceFilePath newFilePath c

Full Usage: replaceFilePath newFilePath c

Parameters:
    newFilePath : FilePath - The new file path to use as a replacement
    c : CreateProcess<'a> - The create process instance

Returns: CreateProcess<'a>

Replace the file-path

newFilePath : FilePath

The new file path to use as a replacement

c : CreateProcess<'a>

The create process instance

Returns: CreateProcess<'a>

setEnvironmentVariable envKey envVar c

Full Usage: setEnvironmentVariable envKey envVar c

Parameters:
    envKey : string - The environment variable key
    envVar : string - The environment variable value
    c : CreateProcess<'a> - The create process instance

Returns: CreateProcess<'a>

Set the given environment variable.

envKey : string

The environment variable key

envVar : string

The environment variable value

c : CreateProcess<'a>

The create process instance

Returns: CreateProcess<'a>

warnOnExitCode msg r

Full Usage: warnOnExitCode msg r

Parameters:
Returns: CreateProcess<'a>

LikeensureExitCode but only triggers a warning instead of failing.

msg : string
r : CreateProcess<'a>
Returns: CreateProcess<'a>

withCommand command c

Full Usage: withCommand command c

Parameters:
    command : Command - The command to add to create process instance
    c : CreateProcess<'a> - The create process instance

Returns: CreateProcess<'a>

Set the command to the given one.

command : Command

The command to add to create process instance

c : CreateProcess<'a>

The create process instance

Returns: CreateProcess<'a>

withEnvironment env c

Full Usage: withEnvironment env c

Parameters:
    env : (string * string) list - The environment variables list to add
    c : CreateProcess<'a> - The create process instance

Returns: CreateProcess<'a>

Sets the given environment variables

env : (string * string) list

The environment variables list to add

c : CreateProcess<'a>

The create process instance

Returns: CreateProcess<'a>

withEnvironmentMap env c

Full Usage: withEnvironmentMap env c

Parameters:
    env : EnvMap - The environment variables map to add
    c : CreateProcess<'a> - The create process instance

Returns: CreateProcess<'a>

Sets the given environment map.

env : EnvMap

The environment variables map to add

c : CreateProcess<'a>

The create process instance

Returns: CreateProcess<'a>

withOutputEvents onStdOut onStdErr c

Full Usage: withOutputEvents onStdOut onStdErr c

Parameters:
    onStdOut : string -> unit - Function to add as a standard output handler
    onStdErr : string -> unit - Function to add as a standard error handler
    c : CreateProcess<'a> - The create process instance

Returns: CreateProcess<'a>

Calls the given functions whenever a new output-line is received.

onStdOut : string -> unit

Function to add as a standard output handler

onStdErr : string -> unit

Function to add as a standard error handler

c : CreateProcess<'a>

The create process instance

Returns: CreateProcess<'a>

withOutputEventsNotNull onStdOut onStdErr c

Full Usage: withOutputEventsNotNull onStdOut onStdErr c

Parameters:
    onStdOut : string -> unit - Function to add as a standard output handler
    onStdErr : string -> unit - Function to add as a standard error handler
    c : CreateProcess<'a> - The create process instance

Returns: CreateProcess<'a>

Like withOutputEvents but skips null objects.

onStdOut : string -> unit

Function to add as a standard output handler

onStdErr : string -> unit

Function to add as a standard error handler

c : CreateProcess<'a>

The create process instance

Returns: CreateProcess<'a>

withStandardError stdErr c

Full Usage: withStandardError stdErr c

Parameters:
Returns: CreateProcess<'a>

Set the standard error stream.

stdErr : StreamSpecification
c : CreateProcess<'a>

The create process instance

Returns: CreateProcess<'a>

withStandardInput stdIn c

Full Usage: withStandardInput stdIn c

Parameters:
Returns: CreateProcess<'a>

Set the standard input stream.

stdIn : StreamSpecification

The standard input to use

c : CreateProcess<'a>

The create process instance

Returns: CreateProcess<'a>

withStandardOutput stdOut c

Full Usage: withStandardOutput stdOut c

Parameters:
Returns: CreateProcess<'a>

Set the standard output stream.

stdOut : StreamSpecification

The standard output to use

c : CreateProcess<'a>

The create process instance

Returns: CreateProcess<'a>

withTimeout timeout c

Full Usage: withTimeout timeout c

Parameters:
Returns: CreateProcess<'a>

Set the given timeout, kills the process after the specified timespan

timeout : TimeSpan

The timeout amount

c : CreateProcess<'a>

The create process instance

Returns: CreateProcess<'a>

withWorkingDirectory workDir c

Full Usage: withWorkingDirectory workDir c

Parameters:
    workDir : string - The working directory
    c : CreateProcess<'a> - The create process instance

Returns: CreateProcess<'a>

Set the working directory of the new process.

workDir : string

The working directory

c : CreateProcess<'a>

The create process instance

Returns: CreateProcess<'a>