James Kovacs

Sponsors

The Lounge

Advertisement

Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
Introducing psake

psake 

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 <script.ps1> [task(s)]

(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!


Posted Fri, Jun 27 2008 4:53 PM by james.kovacs
Filed under: , ,

[Advertisement]

Comments

Dew Drop - June 29, 2008 | Alvin Ashcraft's Morning Dew wrote Dew Drop - June 29, 2008 | Alvin Ashcraft's Morning Dew
on Sun, Jun 29 2008 8:00 AM

Pingback from  Dew Drop - June 29, 2008 | Alvin Ashcraft's Morning Dew

DotNetKicks.com wrote Psake a- Powershell based build tool
on Mon, Jun 30 2008 4:54 AM

You've been kicked (a good thing) - Trackback from DotNetKicks.com

Ian Cooper wrote re: Introducing psake
on Mon, Jun 30 2008 4:55 AM

Great stuff James. Looking forward to seeing what we could do with this.

piers7 wrote re: Introducing psake
on Fri, Jul 4 2008 10:27 AM

Phew. I thought I was going to have to write one myself.

Episode 35 – Community Roundtable #2 « PowerScripting Podcast wrote Episode 35 &ndash; Community Roundtable #2 &laquo; PowerScripting Podcast
on Fri, Jul 25 2008 11:47 PM

Pingback from  Episode 35 &ndash; Community Roundtable #2 &laquo; PowerScripting Podcast

W.Meints wrote re: Introducing psake
on Sun, Oct 26 2008 12:46 PM

Great idea James! I use psake for the first time with my photoviewer application and I'm hooked.

It's simple and very extensible. Excellent job!

Building’s the Foundation - Beige Sunshine wrote Building&#8217;s the Foundation - Beige Sunshine
on Tue, Nov 25 2008 12:25 PM

Pingback from  Building&#8217;s the Foundation - Beige Sunshine

Make Utility in PowerShell | keyongtech wrote Make Utility in PowerShell | keyongtech
on Sun, Jan 18 2009 12:31 PM

Pingback from  Make Utility in PowerShell | keyongtech

Derek Morrison wrote Using Ruby and Rake with ASP.NET
on Tue, Mar 31 2009 12:01 PM

Using Ruby and Rake with ASP.NET

Ayende @ Rahien wrote On PSake
on Sun, Aug 30 2009 8:02 AM

On PSake

Lorenzo Melato Weblog wrote Rhino commons e il giardinaggio
on Sun, Nov 1 2009 4:46 PM

Rhino commons e il giardinaggio

Web Log di Lorenzo Melato wrote Rhino commons e il giardinaggio
on Sun, Nov 1 2009 4:46 PM

Rhino commons e il giardinaggio

Add a Comment

(required)  
(optional)
(required)  
Remember Me?