Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass properties to chocolatey version of psake

I've installed psake using Chocolatey. This allows you to run psake using the psake command from either powershell or the windows command line.

However when I try and pass properties to psake using the following command

psake TestProperties -properties @{"tags"="test"}

I get the following error:

PS D:\projects\WebTestAutomation> psake TestProperties -properties @{"tags"="test"}
"& 'C:\Chocolatey\lib\psake.4.2.0.1\tools\\psake.ps1' TestProperties -properties System.Collections.Hashtable
C:\Chocolatey\lib\psake.4.2.0.1\tools\psake.ps1 : Cannot process argument transformation on parameter 'properties'. Cannot convert the "System.Collections.Hashtable" value of
 type "System.String" to type "System.Collections.Hashtable".
At line:1 char:80
+ & 'C:\Chocolatey\lib\psake.4.2.0.1\tools\\psake.ps1' TestProperties -properties <<<<  System.Collections.Hashtable; if ($psake.build_success -eq $false) { exit 1 } else { e
xit 0 }
    + CategoryInfo          : InvalidData: (:) [psake.ps1], ParameterBindin...mationException
    + FullyQualifiedErrorId : ParameterArgumentTransformationError,psake.ps1

Any ideas on how overcome this?

like image 694
Castrohenge Avatar asked Aug 13 '13 12:08

Castrohenge


1 Answers

I solved this by passing the properties Hashtable as a string.

psake TestProperties -properties "@{tags='test'}"

I'd also recommend running the command from the command prompt as opposed to powershell. Because the psake command works by calling a .bat file, which then calls a .cmd which in turn executes a .ps1 file, using ampersands in the properties caused issues when the command was execute from powershell.

For example the following command succesfully runs from the command prompt but errors when run from the powershell console:

psake TestProperties -properties "@{tags='test^&wip'}"

Note the use of ^ to escape the & character.

like image 176
Castrohenge Avatar answered Sep 27 '22 21:09

Castrohenge