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?
I solved this by passing the properties
Hashtableas astring.I'd also recommend running the command from the command prompt as opposed to powershell. Because the
psakecommand works by calling a.batfile, which then calls a.cmdwhich in turn executes a.ps1file, 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:
Note the use of
^to escape the&character.