psake/psake — pull request #22 by whut (2011-10-08 19:49:20+00:00)
Title: Some new ideas

Hi,

I have some new ideas about psake, and I would like hear your comments.

# DerivedProperties

First commit adds DerivedProperties, that's something similar to Properties, but executed later, so it allows writing build script like this:

Properties {
$version_major = "1.0.0"
$version_build = "0"
}

DerivedProperties {
$version = "$version_major.$version_build"
}

Task default -depends ShowVersion

Task ShowVersion {
write-host "Version: $version"
}

# Simplified modules loading

Next commit is about simplifying psake-config.ps1 when comes to loading modules. Now it can be written as:

Don't load anything (default):
$config.modules=$null

Load modules from .\modules folder and from file my_module.psm1:
$config.modules=(".\modules\*.psm1",".\my_module.psm1")

# Required helper function

Next commit adds Required helper function, that checks if all variables passed as arguments are set. I use such function in our deploy scripts, to check if all required parameters to execute some task (like 'CreateWebSiteInIIS') are set. Example:

properties {
$webSiteDir = $null
$webSitePort = $null
}

task default -depends CreateWebSiteInIIS

task CreateWebSiteInIIS {
Required webSiteDir, webSitePort
}

# Marking Include function as deprecated

When I started using psake I used Include function, and I had some problems with it, because I didn't know that files added by Include will be included not at the point of Include call, but after loading whole build script. So because Include behavior is surprising, and what it does can be done just by ". somefile.ps1", I believe that it should be deprecated.