psake 4.2.0 error using command line properties argument

Skip to first unread message

Mike Duran

Mar 11, 2013, 5:02:46 PM3/11/13
What am I doing wrong?  I can't seem to get the -properties argument to work.  I get the error below.

psake 4.2.0

properties {
$environment = "trunk"

task default -depends init

task init{

write-host $environment

PS C:\temp> psake .\testbuild.ps1 default -properties @{"environment"="trunk"}

C:\Chocolatey\lib\psake.\tools\psake.ps1 : Cannot process argument transformation on parameter 'properties'. Can
not convert the "System.Collections.Hashtable" value of type "System.String" to type "System.Collections.Hashtable".
At line:1 char:89
+ & 'C:\Chocolatey\lib\psake.\tools\\psake.ps1' .\testbuild.ps1 default -properties <<<<  System.Collections.Has
htable; if ($psake.build_success -eq $false) { exit 1 } else { exit 0 }
    + CategoryInfo          : InvalidData: (:) [psake.ps1], ParameterBindin...mationException
    + FullyQualifiedErrorId : ParameterArgumentTransformationError,psake.ps1

Valera Kolupaev

Apr 3, 2014, 11:22:06 AM4/3/14
Hi Mike, 

I had the same problem, as you.
It seems that the root of the problem, is that psake is installed using chocolatey installs "psake.bat" shell tool. So the parameters are converted to windows shell string first, and then converted back. 

The solution I have found, is to import psake module directly into powershell and use Invoke-Psake, instead of psake.bat.

PS C:\dev\XXX\apiserver\scripts> Import-Module C:\Chocolatey\lib\psake.\tools\psake
PS C:\dev\XXX\apiserver\scripts> invoke-psake upload_api -properties $prop

Mike Duran

Apr 10, 2014, 2:55:21 PM4/10/14
Thanks.  I have stopped using the psake.bat file ...and now just use the invoke-psake like you suggest..
Reply all
Reply to author
0 new messages