Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell Psake包含方法不起作用_Powershell_Psake - Fatal编程技术网

Powershell Psake包含方法不起作用

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

我正在用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));
}
代码成功地通过了断言行

问题来自解析路径$fileNamePathToInclude,它不返回任何内容。。。 如果我从命令行尝试,效果很好


以前有人遇到过此问题吗?

包含文件的方式不是
include.\EnvSettings.ps1
,而是“点源”文件:

. .\EnvSettings.ps1