【发布时间】:2013-09-04 14:58:47
【问题描述】:
我正在使用 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
+ $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));
}
代码成功通过了 Assert 行。
问题来自 Resolve-Path $fileNamePathToInclude,它什么也没返回... 如果我从命令行尝试它,它工作正常。
以前有人遇到过这个问题吗?
【问题讨论】:
标签: powershell psake