psake - 如何将属性传递给巧克力版本的 psake

标签 psake chocolatey

我已经使用 Chocolatey 安装了 psake。这允许您使用 psake 运行 psake来自 powershell 或 windows 命令行的命令。

但是,当我尝试使用以下命令将属性传递给 psake 时

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

我收到以下错误:
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

关于如何克服这个问题的任何想法?

最佳答案

我通过传递属性 Hashtable 解决了这个问题作为 string .

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

我还建议从命令提示符而不是 powershell 运行命令。因为psake命令通过调用 .bat 起作用文件,然后调用 .cmd依次执行 .ps1文件中,在属性中使用&符号会导致从 powershell 执行命令时出现问题。

例如,以下命令从命令提示符成功运行,但从 powershell 控制台运行时出错:
psake TestProperties -properties "@{tags='test^&wip'}"

注意使用 ^逃离&特点。

关于psake - 如何将属性传递给巧克力版本的 psake,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18209467/

相关文章:

powershell - TeamCity 不使用 powershell 显示服务消息

powershell - 在 PowerShell 中使用 Chocolatey 辅助函数

packages - 什么是 Chocolatey "Install"包?

powershell - Powershell 3.0 中的与号行为是否发生了变化?

powershell - CSPack 和 CSRun 用于从 powershell 在 azure 模拟器中运行站点

.net - .NET 构建的 psake 与 rake

windows - Chocolatey 在本地安装,但不在 docker 构建中安装(但上周安装了) - 为什么?

chocolatey - 如何卸载 Chocolatey 包及其所有依赖项?

powershell - 如何在 psake 中调用 exec 到具有可变路径的可执行文件?

continuous-integration - Psake 是做什么用的?