A build automation tool… now with less XML…
psake is a build automation tool written in PowerShell. It avoids the angle-bracket tax associated with executable XML by leveraging the PowerShell syntax in your build scripts. psake has a syntax inspired by rake (aka make in Ruby) and bake (aka make in Boo), but is easier to script because it leverages your existent command-line knowledge.
psake is pronounced sake – as in Japanese rice wine. It does NOT rhyme with make, bake, or rake.
psake is a proof-of-concept still in the early stages of development. It consists of a single file, psake.ps1, which contains all the logic for creating a graph of dependent tasks and executing them in the correct order. You can download it from Google Code using Subversion or TortoiseSVN:
svn checkout http://psake.googlecode.com/svn/trunk/ psake-read-only
Here is a simple psake build script:
properties {
$testMessage = ‘Executed Test!’
$compileMessage = ‘Executed Compile!’
$cleanMessage = ‘Executed Clean!’
}
task default -depends Test
task Test -depends Compile, Clean {
Write-Host $testMessage
}
task Compile -depends Clean {
Write-Host $compileMessage
}
task Clean {
Write-Host $cleanMessage
}
The properties and task script blocks can contain any valid PowerShell commands. To execute the script, simply type:
psake
(This assumes that psake.ps1 is in your PowerShell path.) If you don’t specify a task or list of tasks (separated by spaces), it will look for a task named “default”. You can display the command line syntax by typing:
psake -help
psake [buildFile] [tasks] [-framework ver] [-debug]
where buildFile is the name of the build file, (default: default.ps1)
tasks is a list of tasks to execute from the build file,
ver is the .NET Framework version to target – 1.0, 1.1, 2.0, 3.0, or 3.5
3.5 is the default
debug dumps information the tasks.
psake -help
Displays this message.
Remember that psake is syntactic sugar around PowerShell. So anything you can do in PowerShell, you can do in psake. That means that you can run MSBuild, NAnt, or other scripts. There is no need to completely replace your current build system. You can use psake to automate and extend it!
psake automatically adds the appropriate version of .NET Framework to its path. So you can access MSBuild, csc.exe, vbc.exe, or any other tools installed in $env:windir\Microsoft.NET\Framework\$version\ without the fully qualified path.
task default -depends DisplayNotice
task DisplayNotice {
msbuild /version
}
As I mentioned earlier, psake is a proof-of-concept. You’re likely to find some rough edges. I am releasing to the community under a MIT License. I would love to get your feedback and ideas for improving it. If you are interested in contributing, please contact me. Go forth and free yourselves from the shackles of executable XML! Take a sip of psake and enjoy!