Search code examples
powershellpsake

Error passing Parameters with PSake 4.1.0


I'm trying to utilize the parameter feature introduced in the v4 release, but I'm running into an error. I can only seem to get properties to work...and I have tried passing the parameters using single quotes and double quotes around both. I used this post as an example: https://groups.google.com/forum/?fromgroups#!topic/psake-users/UKX3tBzOASE

Any help here is greatly appreciated - I can also zip up the files if someone wants to try and run them locally.

Executing Call:

PowerShell .\_nuget\packages\psake.4.1.0\tools\psake.ps1 sampleScript.ps1 -parameters @{environmentNumber=%TestEnvironmentNumber%}

sampleScript.ps1 contents:

parameters {
    $environmentNumber = $null
}

Task default -depends Print-Properties
Task Print-Properties {
    Assert($environmentNumber -ne $null) "environmentNumber should not be null"
    Write-Host "Environment Number: $environmentNumber"
}

Execution Output:

c:\dev\HgSilver\_Provision\NebTestEnvironment>PowerShell .\_nuget\packages\psake.4.1.0\tools\psake.ps1 sampleScript.ps1 -parameters @{environmentNumber=0} 
psake version 4.1.0
Copyright (c) 2010 James Kovacs

Warning: Using global variable $framework to set .NET framework version used is deprecated. Instead use Framework function or configuration file psake-config.ps1.
Executing Print-Properties
3/26/2012 4:19:10 PM: An Error Occurred: 
Assert: environmentNumber should not be null
At     C:\dev\HgSilver\_Provision\NebTestEnvironment\_nuget\packages\psake.4.1.0\tools\psake.psm1:152 char:14
+         throw <<<<  ("Assert: " + $failureMessage) 
+ CategoryInfo          : OperationStopped: (Assert: environ...uld not be null:String) [], 
RuntimeException
+ FullyQualifiedErrorId : Assert: environmentNumber should not be null

I've also posted this on the psake forums, but I'm waiting for the topic to be approved: https://groups.google.com/forum/?fromgroups#!forum/psake-users


Solution

  • There is not section called parameters in PSake, use properties instead.