首先我遇到了这个问题:无法在 VSCode for Mac 中初始化 PowerShell 会话
我编辑了脚本,现在它不会抛出那个错误,它只是挂起,我无法运行任何命令:
我可以看到它仍然挂着:$editorServicesHost.WaitForCompletion()
查看脚本写入的 $LogPath 文件,我发现此错误:
2020-03-01 09:37:55.677 [NORMAL] tid:9 in 'StartLogging' D:\a\1\s\src\PowerShellEditorServices.Host\EditorServicesHost.cs: line 183
PowerShell Editor Services Host v1.13.3.0 starting (PID 77480
Host application details:
Name: Visual Studio Code Host
Version: 2020.1.0
ProfileId: Microsoft.VSCode
Arch: X64
Operating system details:
Version: Darwin 18.6.0 Darwin Kernel Version 18.6.0: Thu Apr 25 23:16:27 PDT 2019; root:xnu-4903.261.4~2/RELEASE_X86_64
Arch: X64
Build information:
Version:
Origin: VSTS
Date: 2020-01-13T23:11:01
2020-03-01 09:37:55.699 [NORMAL] tid:9 in 'StartLanguageService' D:\a\1\s\src\PowerShellEditorServices.Host\EditorServicesHost.cs: line 202
Language service started, type = NamedPipe, endpoint = InOut pipe: PSES_esjyfps3.oyj
2020-03-01 09:37:55.706 [NORMAL] tid:9 in 'StartDebugService' D:\a\1\s\src\PowerShellEditorServices.Host\EditorServicesHost.cs: line 279
Debug service started, type = NamedPipe, endpoint = InOut pipe: PSES_solbdwjg.nfn
2020-03-01 09:37:57.114 [ERROR] tid:4 in 'ListenForConnection' D:\a\1\s\src\PowerShellEditorServices.Protocol\MessageProtocol\Channel\NamedPipeServerListener.cs: line 155
Exception: An unhandled exception occurred while listening for a named pipe client connection
System.IO.FileNotFoundException: Could not load file or assembly 'Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'. The system cannot find the file specified.
File name: 'Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'
at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageWriter..ctor(Stream outputStream, IMessageSerializer messageSerializer, ILogger logger)
at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.Channel.NamedPipeServerChannel.Initialize(IMessageSerializer messageSerializer)
at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.Channel.ServerListenerBase`1.OnClientConnect(TChannel channel)
at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.Channel.NamedPipeServerListener.<<ListenForConnection>b__9_0>d.MoveNext()
答案1
将 powershell 6.0.3 升级到 6.2.4 解决了这个问题