Skip to content
Oleg edited this page May 6, 2017 · 1 revision

Shell (execute shell command) task

Requires version 0.10.x

Runs the shell (system) command.

Shell task accepts settings of the ShellOptions type:

type ShellOptions = {
    Command: string
    Args: string seq
    LogPrefix:string
    StdOutLevel: string -> Level; ErrOutLevel: string -> Level
    EnvVars: (string * string) list
    WorkingDir: string option

    /// Indicates command has to be executed under mono/.net runtime
    UseClr: bool
    FailOnErrorLevel: bool
}
Name Default value Description
Command - command to execute
Args - arguments, list of strings
StdOutLevel fun _ -> Info defined the output level for stdout output (called for each line)
ErrOutLevel fun _ -> Error the same as above for stderr
EnvVars - Allows to define environment variables for executed shell command
WorkingDir - Sets the current directory
UseClr - prefix the command with "mono" under linux
FailOnErrorLevel false Instruct task to fail if command returned non-zero result

Command is available via both common and simplified syntax:

open Xake.SystemTasks
...
do! Shell {ShellOptions.Default with
            Command = "dir"; Args = ["*.*"]
            WorkingDir = Some "."; UseClr = true; FailOnErrorLevel = true}
/// or simplified syntax:
let! error = shell {
    cmd "dir"
    args ["*.*"]
    workdir "."
    }
Clone this wiki locally