Search code examples
powershellpowershell-2.0psake

Error when executing Invoke-psake without parameters


I just installed psake version 4.2.0.

I put this in default.ps1

properties {
    $message = "Task A executed"
}

task default -depends taskA

task taskA {
    write-host $taskAmessage
}

If I run Invoke-psake taskA, then the task is executed as expected.

When I execute Invoke-psake without any parameters, just like in the introduction, I get the following error:

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

In my powershell profile, I am importing the psake module everytime I run Powershell.

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

There is this exact issue raised in the project page, but it doesn't seem solved. How do I fix this?


Solution

  • it seems there's something wrong with the module code, you may need to modify line 269 of psake.psm1 into:

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