I am writing a simple PS script with Psake and I have a problem when I try to include another ps1 file.
PS C:\CI> Include .\EnvSettings.ps1
I have this exception
Exception calling "Peek" with "0" argument(s): "Stack empty."
At C:\Users\Julien\Documents\WindowsPowerShell\Modules\psake\psake.psm1:227 char:2
+ $psake.context.Peek().includes.Enqueue(($pa));
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : InvalidOperationException
I had a look at psake.psm1 line 227 to see what's going on around
# .ExternalHelp psake.psm1-help.xml
function Include {
[CmdletBinding()]
param(
[Parameter(Position=0,Mandatory=1)][string]$fileNamePathToInclude
)
Assert (test-path $fileNamePathToInclude -pathType Leaf) ($msgs.error_invalid_include_path -f $fileNamePathToInclude)
$psake.context.Peek().includes.Enqueue((Resolve-Path $fileNamePathToInclude));
}
The code succesfully pass the Assert line.
The problem comes from the Resolve-Path $fileNamePathToInclude, it returns nothing... If I try it from the command line it works fine.
Anyone experienced this problem before?
The way to include a file is not
Include .\EnvSettings.ps1
, but just "dot source" the file :