Note: This API documentation is for FAKE version 4. The migration API documentation can be found here. The API documentation for the new fake 5 modules can be found here

TargetHelper

Contains infrastructure code and helper functions for FAKE's target feature.

Nested types and modules

TypeDescription
BuildError

Represents build errors

DependencyLevel
DependencyType
Target

A Target can be run during the build

ModuleDescription
ExitCode

Functions and values

Function or valueDescription
( <== ) x ys
Signature: x:string -> ys:string list -> unit

Backwards dependencies operator - x is dependent on ys.

ActivateBuildFailureTarget(name)
Signature: name:string -> unit

Activates the BuildFailureTarget.

ActivateFinalTarget(name)
Signature: name:string -> unit

Activates the FinalTarget.

addExecutedTarget target time
Signature: target:string -> time:TimeSpan -> unit
BuildFailureTarget name body
Signature: name:string -> body:(unit -> unit) -> unit

Registers a BuildFailureTarget (not activated).

BuildFailureTargets
Signature: Dictionary<string,bool>

BuildFailureTargets - stores build failure targets and if they are activated.

changeExitCodeIfErrorOccured()
Signature: unit -> unit
CurrentTarget
Signature: string
CurrentTargetOrder
Signature: string list list
dependencyString(target)
Signature: target:'?10305 TargetTemplate -> string
Type parameters: '?10305

Returns the DependencyString for the given target.

determineBuildOrder target parallelJobs
Signature: target:string -> parallelJobs:int -> unit TargetTemplate [] list

Determines a parallel build order for the given set of targets

doesTargetMeanListTargets(target)
Signature: target:string -> bool
doesTargetMeanPrintDotGraph(target)
Signature: target:string -> bool

Gets a flag indicating that the user requested to output a DOT-graph of target dependencies instead of building a target.

DoNothing()
Signature: unit -> unit

Do nothing - fun () -> () - Can be used to define empty targets.

errors
Signature: BuildError list
ExecutedTargets
Signature: HashSet<string>

The executed targets.

FinalTarget name body
Signature: name:string -> body:(unit -> unit) -> unit

Registers a final target (not activated).

FinalTargets
Signature: Dictionary<string,bool>

Final Targets - stores final targets and if they are activated.

getAllTargetsNames()
Signature: unit -> string list

Returns a list with all target names.

GetErrors()
Signature: unit -> BuildError list

Get Errors - Returns the errors that occured during execution

getTarget(name)
Signature: name:string -> unit TargetTemplate

Gets a target with the given name from the target dictionary.

listTargets()
Signature: unit -> unit

Prints all available targets.

PrintDependencyGraph verbose target
Signature: verbose:bool -> target:string -> unit

Writes a dependency graph.

PrintDotDependencyGraph()
Signature: unit -> unit

Writes a dependency graph of all targets in the DOT format.

PrintRunningOrder()
Signature: unit -> unit
PrintTargets()
Signature: unit -> unit

Prints all targets.

run(targetName)
Signature: targetName:string -> unit

Runs a target and its dependencies.

runSingleTarget(target)
Signature: target:unit TargetTemplate -> unit

Runs a single target without its dependencies

runTargets(targets)
Signature: targets:unit TargetTemplate array -> unit
runTargetsParallel count targets
Signature: count:int -> targets:Target [] -> unit

Runs the given array of targets in parallel using count tasks

softDependencyString(target)
Signature: target:'?10307 TargetTemplate -> string
Type parameters: '?10307

Returns the soft DependencyString for the given target.

Target name body
Signature: name:string -> body:(unit -> unit) -> unit

Creates a Target.

TargetTemplate(body)
Signature: body:('?10329 -> unit) -> string -> '?10329 -> unit
Type parameters: '?10329

Creates a TargetTemplate.

TargetTemplateWithDependecies(...)
Signature: dependencies:string list -> ('?10327 -> unit) -> string -> '?10327 -> unit
Type parameters: '?10327 Attributes:
[<Obsolete("Use TargetTemplateWithDependencies")>]
OBSOLETE

Use TargetTemplateWithDependencies

TargetTemplateWithDependencies(...)
Signature: dependencies:string list -> body:('?10325 -> unit) -> name:string -> parameters:'?10325 -> unit
Type parameters: '?10325

Creates a TargetTemplate with dependencies.

Sample

The following sample creates 4 targets using TargetTemplateWithDependencies and hooks them into the build pipeline.

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
15: 
16: 
17: 
18: 
19: 
20: 
21: 
22: 
23: 
24: 
25: 
26: 
27: 
28: 
29: 
30: 
31: 
32: 
// Create target creation functions
let createCompileTarget name strategy =
TargetTemplateWithDependencies
    ["Clean"; "ResolveDependencies"] // dependencies to other targets
    (fun targetParameter ->
      tracefn "--- start compile product..."
      if targetParameter = "a" then
        tracefn "    ---- Strategy A"
      else
        tracefn "    ---- Strategy B"
      tracefn "--- finish compile product ..."
    ) name strategy

let createTestTarget name dependencies filePattern =
  TargetTemplateWithDependencies
    dependencies
    (fun filePattern ->
      tracefn "--- start compile tests ..."
      !! filePattern
      |> RunTests
      tracefn "--- finish compile tests ...")
    name filePattern

// create some targets
createCompileTarget "C1" "a"
createCompileTarget "C2" "b"

createTestTarget "T1" ["C1"] "**/C1/*.*"
createTestTarget "T2" ["C1"; "C2"] "**/C?/*.*"

// hook targets to normal build pipeline
"T1" ==> "T2" ==> "Test"
val createCompileTarget : name:'a -> strategy:'b -> obj
val name : 'a
val strategy : 'b
val createTestTarget : ('c -> 'd -> 'e -> 'f)
val name : 'c
val dependencies : 'd
val filePattern : 'e
visitDependencies fVisit targetName
Signature: fVisit:(unit TargetTemplate option * unit TargetTemplate * DependencyType * int * bool -> unit) -> targetName:string -> HashSet<string> * List<string>
withDependencyType depType targets
Signature: depType:DependencyType -> targets:'?10349 list -> (DependencyType * '?10349) list
Type parameters: '?10349
WriteErrors()
Signature: unit -> unit

Writes a summary of errors reported during build.

WriteTaskTimeSummary(total)
Signature: total:'?10356 -> unit
Type parameters: '?10356

Writes a build time report.