在加载带有函数的脚本时,PowerShell会话已终止

问题描述 投票:0回答:2

加载带有函数的脚本后,Powershell扩展会崩溃

它工作正常,直到我安装Visual Studio社区为PowerShell GUI制作WPF项目安装后,Powershell扩展开始崩溃。现在所有包含函数的文件都会崩溃Powershell扩展。这在打开文件的几秒钟内发生。当我注释掉该函数并重新启动Powershell扩展时,它可以工作,我可以调试。

我重新安装了VS代码和powershell的扩展,但到目前为止还没有运气。我将问题简化为:

\#function getservice(){

get-service

\#}

以上工作正常,但一旦我发表评论,它就会崩溃。一旦我使用包含函数的脚本移动到选项卡,它就会崩溃

扩展主机日志:

TypeError: Cannot read property 'command' of undefined    at resolveFunc
(C:\Users\sce44459\.vscode\extensions\ms-vscode.powershell-1.12.0\out\src\session.js:254:39)  
[2019-04-09 14:24:21.006] [exthost] [error] [ms-vscode.powershell]
provider FAILED  
[2019-04-09 14:24:21.006] [exthost] [error] TypeError:
Cannot read property 'command' of undefined```

扩展日志:

9.4.2019 14:18:46 [NORMAL] - Path specified by 'powerShellExePath' setting - '' - not found, reverting to default PowerShell path.  
9.4.2019 14:18:46 [NORMAL] - Language server starting --  
9.4.2019 14:18:46 [NORMAL] -     exe: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe  
9.4.2019 14:18:46 [NORMAL] -     args: C:\Users\sce44459\.vscode\extensions\ms-vscode.powershell- 
 1.12.0\modules\PowerShellEditorServices\Start-EditorServices.ps1
-HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '1.12.0' -AdditionalModules @('PowerShellEditorServices.VSCode') -BundledModulesPath
'C:\Users\sce44459\.vscode\extensions\ms-vscode.powershell-1.12.0\modules'
-EnableConsoleRepl -LogLevel 'Normal' -LogPath 'C:\Users\sce44459\.vscode\extensions\ms-vscode.powershell-1.12.0\logs\1554812326-d490a1a0-df66-47c6-a741-74dc46a8873b1554810449036\EditorServices.log' -SessionDetailsPath 'C:\Users\sce44459\.vscode\extensions\ms-vscode.powershell-1.12.0\sessions\PSES-VSCode-5164-189789'
-FeatureFlags @()  
9.4.2019 14:18:47 [NORMAL] - powershell.exe started, pid: 6372  
9.4.2019 14:18:50 [NORMAL] - Language server started.  
9.4.2019 14:18:50 [NORMAL] - {"languageServiceTransport":"NamedPipe","languageServicePipeName":"\\\\.\\pipe\\PSES_gbzaczkk.xnh","debugServiceTransport":"NamedPipe","status":"started","debugServicePipeName":"\\\\.\\pipe\\PSES_3w4pqudu.4xm"}  
9.4.2019 14:18:50 [NORMAL] - Connecting to language service on pipe \\.\pipe\PSES_gbzaczkk.xnh...  
9.4.2019 14:18:50 [NORMAL] - Language service connected.  
9.4.2019 14:18:57 [NORMAL] - powershell.exe terminated or terminal UI was closed```
Windows 2012

Version: 1.33.0 (system setup)
Commit: `0dd516dd412d42323fc3464531b1c715d51c4c1a`
Date: 2019-04-04T15:14:28.026Z
Electron: 3.1.6
Chrome: 66.0.3359.181
Node.js: 10.2.0
V8: 6.6.346.32
OS: Windows_NT x64 6.3.9600

我无法在事件日志中找到更多内容。是否有人知道什么可能导致这个或什么信息可以帮助调试这个?

powershell visual-studio-code
2个回答
0
投票

我在使用VS Code连接到远程会话时遇到了同样的问题,从VS Code获得了相同的输出。通过卸载然后重新安装PowerShell扩展,我能够解决此问题。希望这可以帮助。


0
投票

我似乎终于破解了它。重新安装不起作用(重新安装后我注意到我的所有模块仍然存在)。我现在卸载了所有模块(powershell,git history,git项目管理器,git镜头)。然后我卸载了VS code-> reboot-> re-install->重新安装Powershell模块。现在它有效。

我希望它可以帮助别人,并感谢所有花时间看一看的人,非常感谢。

© www.soinside.com 2019 - 2024. All rights reserved.