This is part of the Fake.Core.Process module.

CreateProcess

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

1: 
2: 
3: 
4: 
Command.RawCommand("file", Arguments.OfArgs ["arg1"; "arg2"])
|> CreateProcess.fromCommand
|> Proc.run
|> ignore
val ignore : value:'T -> unit

Functions and values

Function or valueDescription
addOnExited f c
Signature: f:('?9326 -> int -> '?9327) -> c:CreateProcess<'?9326> -> CreateProcess<'?9327>
Type parameters: '?9326, '?9327

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

addOnFinally f c
Signature: f:(unit -> unit) -> c:CreateProcess<'?9296> -> CreateProcess<'?9296>
Type parameters: '?9296

Execute the given function when the process is cleaned up.

addOnSetup f c
Signature: f:(unit -> '?9293) -> c:CreateProcess<'?9294> -> CreateProcess<'?9294>
Type parameters: '?9293, '?9294

Execute the given function before the process is started

addOnStarted f c
Signature: f:(unit -> unit) -> c:CreateProcess<'?9298> -> CreateProcess<'?9298>
Type parameters: '?9298

Execute the given function right after the process is started.

appendSimpleFuncs(...)
Signature: prepareState:(unit -> '?9289) -> onStart:('?9289 -> Process -> unit) -> onResult:(Async<'?9290> -> '?9289 -> Task<RawProcessResult> -> Async<'?9291>) -> onDispose:('?9289 -> unit) -> c:CreateProcess<'?9290> -> CreateProcess<'?9291>
Type parameters: '?9289, '?9290, '?9291

Attaches the given functions to the current CreateProcess instance.

copyRedirectedProcessOutputsToStandardOutputs(...)
Signature: c:CreateProcess<'?9240> -> CreateProcess<'?9240>
Type parameters: '?9240

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

disableTraceCommand(c)
Signature: c:CreateProcess<'?9244> -> CreateProcess<'?9244>
Type parameters: '?9244

Disable the default trace of started processes.

ensureExitCode(r)
Signature: r:CreateProcess<'?9332> -> CreateProcess<'?9332>
Type parameters: '?9332

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

ensureExitCodeWithMessage msg r
Signature: msg:string -> r:CreateProcess<'?9329> -> CreateProcess<'?9329>
Type parameters: '?9329

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

fromCommand(command)
Signature: command:Command -> CreateProcess<ProcessResult<unit>>

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

Example

1: 
2: 
3: 
4: 
Command.RawCommand("file", Arguments.OfArgs ["arg1"; "arg2"])
|> CreateProcess.fromCommand
|> Proc.run
|> ignore
val ignore : value:'T -> unit
fromRawCommand command args
Signature: command:FilePath -> args:seq<string> -> CreateProcess<ProcessResult<unit>>

Create a CreateProcess from the given file and arguments

Example

1: 
2: 
3: 
CreateProcess.fromRawCommand "cmd" [ "/C";  "echo test" ]
|> Proc.run
|> ignore
val ignore : value:'T -> unit
fromRawCommandLine(...)
Signature: command:FilePath -> windowsCommandLine:string -> CreateProcess<ProcessResult<unit>>

Create a CreateProcess from the given file and arguments

Example

1: 
2: 
3: 
CreateProcess.fromRawCommandLine "cmd" "/C \"echo test\""
|> Proc.run
|> ignore

Using BlackFox.CommandLine

See BlackFox.CommandLine for details

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
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
val ignore : value:'T -> unit
fromRawWindowsCommandLine(...)
Signature: command:FilePath -> windowsCommandLine:string -> CreateProcess<ProcessResult<unit>>
Attributes:
[<Obsolete("Use fromRawCommandLine instead.")>]
OBSOLETE

Use fromRawCommandLine instead.

Create a CreateProcess from the given file and arguments

getEnvironmentMap(c)
Signature: c:CreateProcess<'?9304> -> EnvMap
Type parameters: '?9304

Retrieve the current environment map.

interceptStream target s
Signature: target:Stream -> s:StreamSpecification -> StreamSpecification

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

map f c
Signature: f:('?9314 -> '?9315) -> c:CreateProcess<'?9314> -> CreateProcess<'?9315>
Type parameters: '?9314, '?9315

Map the current result to a new type.

mapFilePath f c
Signature: f:(FilePath -> FilePath) -> c:CreateProcess<'?9250> -> CreateProcess<'?9250>
Type parameters: '?9250

Map the file-path according to the given function.

mapResult f c
Signature: f:('a -> 'b) -> c:CreateProcess<ProcessResult<'a>> -> CreateProcess<ProcessResult<'b>>
Type parameters: 'a, 'b

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

ofStartInfo(p)
Signature: p:ProcessStartInfo -> CreateProcess<ProcessResult<unit>>

Create a CreateProcess from the given ProcessStartInfo

redirectOutput(c)
Signature: c:CreateProcess<'a> -> CreateProcess<ProcessResult<ProcessOutput>>
Type parameters: 'a

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

replaceFilePath newFilePath c
Signature: newFilePath:FilePath -> c:CreateProcess<'?9248> -> CreateProcess<'?9248>
Type parameters: '?9248

Replace the file-path

setEnvironmentVariable envKey envVar c
Signature: envKey:string -> envVar:string -> c:CreateProcess<'?9306> -> CreateProcess<'?9306>
Type parameters: '?9306

Set the given environment variable.

warnOnExitCode msg r
Signature: msg:string -> r:CreateProcess<unit> -> CreateProcess<unit>

LikeensureExitCode but only triggers a warning instead of failing.

withCommand command c
Signature: command:Command -> c:CreateProcess<'?9246> -> CreateProcess<'?9246>
Type parameters: '?9246

Set the command to the given one.

withEnvironment env c
Signature: env:(string * string) list -> c:CreateProcess<'?9300> -> CreateProcess<'?9300>
Type parameters: '?9300

Sets the given environment variables

withEnvironmentMap env c
Signature: env:EnvMap -> c:CreateProcess<'?9302> -> CreateProcess<'?9302>
Type parameters: '?9302

Sets the given environment map.

withOutputEvents onStdOut onStdErr c
Signature: onStdOut:(string -> unit) -> onStdErr:(string -> unit) -> c:CreateProcess<'a> -> CreateProcess<'a>
Type parameters: 'a

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

withOutputEventsNotNull(...)
Signature: onStdOut:(string -> unit) -> onStdErr:(string -> unit) -> c:CreateProcess<'?9324> -> CreateProcess<'?9324>
Type parameters: '?9324

Like withOutputEvents but skips null objects.

withStandardError stdErr c
Signature: stdErr:StreamSpecification -> c:CreateProcess<'?9310> -> CreateProcess<'?9310>
Type parameters: '?9310

Set the standard error stream.

withStandardInput stdIn c
Signature: stdIn:StreamSpecification -> c:CreateProcess<'?9312> -> CreateProcess<'?9312>
Type parameters: '?9312

Set the standard input stream.

withStandardOutput stdOut c
Signature: stdOut:StreamSpecification -> c:CreateProcess<'?9308> -> CreateProcess<'?9308>
Type parameters: '?9308

Set the standard output stream.

withTimeout timeout c
Signature: timeout:TimeSpan -> c:CreateProcess<'a> -> CreateProcess<'a>
Type parameters: 'a

Set the given timeout

withWorkingDirectory workDir c
Signature: workDir:string -> c:CreateProcess<'?9242> -> CreateProcess<'?9242>
Type parameters: '?9242

Set the working directory of the new process.