Skip to content

Introduction to Psake

Terminal window
Task Rebuild -Depends Clean, Build {
"Rebuild"
}
Task Build {
"Build"
}
Task Clean {
"Clean"
}
Task default -Depends Build
Terminal window
# Will display task as:
# -------- Rebuild --------
# -------- Build --------
FormatTaskName "-------- {0} --------"
# will display tasks in yellow colour:
# Running Rebuild
FormatTaskName {
param($taskName)
"Running $taskName" - foregroundcolor yellow
}
Task Rebuild -Depends Clean, Build {
"Rebuild"
}
Task Build {
"Build"
}
Task Clean {
"Clean"
}
Task default -Depends Build
Terminal window
propreties {
$isOk = $false
}
# By default the Build task won't run, unless there is a param $true
Task Build -precondition { return $isOk } {
"Build"
}
Task Clean {
"Clean"
}
Task default -Depends Build
Terminal window
Task Build -depends Clean {
"Build"
}
Task Clean -ContinueOnError {
"Clean"
throw "throw on purpose, but the task will continue to run"
}
Task default -Depends Build
  • Task - main function to execute a step of your build script
  • Depends - property that specify what the current step depends upon
  • default - there must always be a default task that will get executed if no initial task is specified
  • FormatTaskName - specifies how each step is displayed in the result window.

psake is a build automation tool written in PowerShell, and is inspired by Rake (Ruby make) and Bake (Boo make). It is used to create builds using dependency pattern. Documentation available here