forked from psake/psake
-
Notifications
You must be signed in to change notification settings - Fork 0
How can I override a property defined in my psake script?
dlidstrom edited this page Feb 16, 2011
·
2 revisions
You can override a property in your build script using the “properties” parameter of the Invoke-psake function. The following is an example:
C:\PS>Invoke-psake .\properties.ps1 -properties @{"x"="1";"y"="2"}
The example above runs the build script called “properties.ps1” and passes in parameters ‘x’ and ‘y’ with values ‘1’ and ‘2’. The parameter value for the “properties” parameter is a PowerShell hashtable where the name and value of each property is specified. Note: You don’t need to use the “$” character when specifying the property names in the hashtable.
The “properties.ps1” build script looks like this:
properties { $x = $null $y = $null $z = $null } task default -depends TestProperties task TestProperties { Assert ($x -ne $null) "x should not be null" Assert ($y -ne $null) "y should not be null" Assert ($z -eq $null) "z should be null" }
The value of $x should be 1 and $y should be 2 by the time the “TestProperties” task is executed. The value of $z was not over-ridden so it should still be $null.