1
我想利用v4版本中引入的參數功能,但我遇到了一個錯誤。我似乎只能得到屬性來工作......並且我已經嘗試在兩個參數中使用單引號和雙引號傳遞參數。我用這個帖子作爲例子: https://groups.google.com/forum/?fromgroups#!topic/psake-users/UKX3tBzOASE錯誤傳遞參數與PSake 4.1.0
這裏的任何幫助非常感謝 - 如果有人想嘗試在本地運行它們,我還可以壓縮文件。
執行CALL:
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
我明白你指出的 - 就是這樣 - 謝謝! – 2012-03-28 19:35:08