执行不带参数的Invoke-psake时出错

时间:2012-12-10 07:27:28

标签: powershell powershell-v2.0 psake

我刚刚安装了psake版本4.2.0。

我把它放在default.ps1

properties {
    $message = "Task A executed"
}

task default -depends taskA

task taskA {
    write-host $taskAmessage
}

如果我运行Invoke-psake taskA,则任务按预期执行。

当我执行Invoke-psake没有任何参数时,就像在introduction中一样,我收到以下错误:

Test-Path : Cannot bind argument to parameter 'Path' because it is an empty string.
At D:\animesh\software\utilities\psake-master\psake-master\psake.psm1:291 char:26
+         Assert (test-path <<<<  $buildFile -pathType Leaf) ($msgs.error_build_file_not_found -f $buildFile)
    + CategoryInfo          : InvalidData: (:) [Test-Path], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Microsoft.PowerShell.Commands.TestPathCommand

在我的powershell配置文件中,每次运行Powershell时我都会导入psake模块。

import-module "D:\animesh\software\utilities\psake-master\psake-master\psake.psm1"

项目页面中出现了exact issue,但似乎没有解决。我该如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

模块代码似乎有问题,您可能需要将psake.psm1的第269行修改为:

[Parameter(Position = 0, Mandatory = 0)][string] $buildFile=$psake.config_default.buildFileName