我正在尝试使用v4版本中引入的参数功能,但我遇到了错误。我似乎只能让属性工作......我尝试使用单引号和双引号传递参数。我以这篇文章为例: https://groups.google.com/forum/?fromgroups#!topic/psake-users/UKX3tBzOASE
非常感谢任何帮助 - 如果有人想尝试在本地运行它们,我也可以压缩文件。
执行电话:
PowerShell .\_nuget\packages\psake.4.1.0\tools\psake.ps1 sampleScript.ps1 -parameters @{environmentNumber=%TestEnvironmentNumber%}
sampleScript.ps1内容:
parameters {
$environmentNumber = $null
}
Task default -depends Print-Properties
Task Print-Properties {
Assert($environmentNumber -ne $null) "environmentNumber should not be null"
Write-Host "Environment Number: $environmentNumber"
}
执行输出:
c:\dev\HgSilver\_Provision\NebTestEnvironment>PowerShell .\_nuget\packages\psake.4.1.0\tools\psake.ps1 sampleScript.ps1 -parameters @{environmentNumber=0}
psake version 4.1.0
Copyright (c) 2010 James Kovacs
Warning: Using global variable $framework to set .NET framework version used is deprecated. Instead use Framework function or configuration file psake-config.ps1.
Executing Print-Properties
3/26/2012 4:19:10 PM: An Error Occurred:
Assert: environmentNumber should not be null
At C:\dev\HgSilver\_Provision\NebTestEnvironment\_nuget\packages\psake.4.1.0\tools\psake.psm1:152 char:14
+ throw <<<< ("Assert: " + $failureMessage)
+ CategoryInfo : OperationStopped: (Assert: environ...uld not be null:String) [],
RuntimeException
+ FullyQualifiedErrorId : Assert: environmentNumber should not be null
我也在psake论坛上发布了这个,但我在等待批准这个话题: https://groups.google.com/forum/?fromgroups#!forum/psake-users
答案 0 :(得分:1)
PSake中没有名为parameters
的部分,而是使用properties
。