Powershell Psake包含方法不起作用
我正在用Psake编写一个简单的PS脚本,当我试图包含另一个ps1文件时遇到了一个问题Powershell Psake包含方法不起作用,powershell,psake,Powershell,Psake,我正在用Psake编写一个简单的PS脚本,当我试图包含另一个ps1文件时遇到了一个问题 PS C:\CI> Include .\EnvSettings.ps1 我有一个例外 Exception calling "Peek" with "0" argument(s): "Stack empty." At C:\Users\Julien\Documents\WindowsPowerShell\Modules\psake\psake.psm1:227 char:2 + $psa
PS C:\CI> Include .\EnvSettings.ps1
我有一个例外
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
我看了psake.psm1第227行,看看周围发生了什么
# .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));
}
代码成功地通过了断言行
问题来自解析路径$fileNamePathToInclude,它不返回任何内容。。。
如果我从命令行尝试,效果很好
以前有人遇到过此问题吗?包含文件的方式不是
include.\EnvSettings.ps1
,而是“点源”文件:
. .\EnvSettings.ps1