Skip to content

Tasks | Inner functions

Oleg edited this page Apr 8, 2017 · 3 revisions

trace level template args

Prints the message to output log. The message is printed if output verbosity level includes message level.

  • Level parameter must take one of the following values: Level.Message, Level.Error, Level.Command, Level.Warning, Level.Info, Level.Debug, Level.Verbose, Level.Never
do! trace Level.Info "Using csc compiler version %s" "1.0"

getTargetFile, getTargetFullName

getTargetFile returns the File of the currently executing target. getTargetFullName return full name of that file.

let! targetFileName = getTargetFullName()
do! trace Level.Info "Compiling %s..." targetFileName

getRuleMatch

Get the matched part of the target file.

See the part of the file name is put in brackets and supplied a group name "root":

"(root:*).exe" ..> recipe {
    let! name = getRuleMatch "root"
    do! csc {src (!!(name + ".cs") ++ "ver.cs")}
}

need [targets], needFiles

need function is widely used internally and it is a key element for dependency tracking. Calling need ensures the requested files are built according to rules. The action is paused until all dependencies are resolved and built.

do! need ["bin/app.exe"; "bin/app.exe.config"]

needFiles function is similar but it accepts list of File objects instead of strings.

getCtxOptions

Gets action context.

getVar name

Gets the script variable value (and records dependency!).

let! dotnetFwk = getVar "NETFX"

where NETFX variable is defined as:

do xake {ExecOptions.Default with Vars = ["NETFX", "4.5"] } {
    ...
// or
do xakeScript {
    var "NETFX" "4.5"
    ...

or passed via command line:

fsi build.fsx -- build -d NETFX=4.5

This command alse records that currently executing target depends on the value of this variable. In case the value of the variable is different from the value of that variable during previous build, the target will be rebuilt.

getEnv name

Gets environment variable (and records dependency!).

let! dotnetFwk = getEnv "USERNAME"

getFiles fileset

Evaluates the fileset to a list of files (of File type). Filesets are always resolved using project root folder (passed in script arguments).

let! (Filelist files) = (!!"hello*.cs") |> getFiles

This command also records dependency and the target will rerun if result of getFiles call is changed during the next run: wheter files were added or removed, or if timestamp of any file is changed.

alwaysRerun

Instructs Xake to rebuild the target even if dependencies are not changed. this is expecially important for phony actions which do not produce a file.

do! alwaysRerun()
Clone this wiki locally