Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top