【问题标题】:Error passing Parameters with PSake 4.1.0使用 PSake 4.1.0 传递参数时出错
【发布时间】:2012-03-26 20:31:01
【问题描述】:

我正在尝试利用 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

【问题讨论】:

    标签: powershell psake


    【解决方案1】:

    PSake 中没有名为parameters 的部分,请改用properties

    【讨论】:

      猜你喜欢
      • 2016-10-08
      • 2013-06-12
      • 2018-02-04
      • 1970-01-01
      • 1970-01-01
      • 2018-10-14
      • 2015-03-16
      • 2022-01-01
      • 1970-01-01
      相关资源
      最近更新 更多