【发布时间】:2020-05-24 06:15:39
【问题描述】:
VS Code 上的 [pwsh] 和 [Powershell 集成控制台] 有什么区别?
我通常使用 pwsh。
今天我安装了powershell扩展,然后尝试更新powershell,powershell集成控制台启动后发现。这是什么?
【问题讨论】:
标签: powershell visual-studio-code
VS Code 上的 [pwsh] 和 [Powershell 集成控制台] 有什么区别?
我通常使用 pwsh。
今天我安装了powershell扩展,然后尝试更新powershell,powershell集成控制台启动后发现。这是什么?
【问题讨论】:
标签: powershell visual-studio-code
pwsh[.exe] 是 PowerShell [Core] (v6+) 的可执行文件名,这是基于 .NET Core / .NET 5 构建的 PowerShell 跨平台版本+;相比之下,powershell.exe 是旧版 Windows PowerShell 版本 (v5.1-) 的可执行名称,它基于仅 Windows 的 .NET Framework (v4.8-) 构建
VSCode (Visual Studio Code) 有一个集成终端(控制台),可以运行任何 shell,例如cmd.exe、bash、pwsh 或powershell。
相比之下,PowerShell 集成控制台 是一个特殊 shell,带有PowerShell extension 和提供与正在编辑的 PowerShell 代码的集成,尤其是提供 linting 和调试支持,以及其他功能。
当您在会话中首次使用 PowerShell 代码打开/激活编辑器时,PowerShell 集成控制台会按需启动,它在集成终端的工具栏中显示如下:
您可以use the PowerShell extension's configuration to choose 选择要使用的特定 PowerShell 可执行文件,在 Windows 上,您可以在 PowerShell 集成控制台中选择运行 PowerShell [Core] (pwsh.exe) 和 Windows PowerShell (powershell.exe)。
如果安装了 PowerShell [Core] 版本并且安装在众所周知的位置[*],则默认使用;后备 Windows 是 Windows PowerShell。由于 PowerShell [Core] 版本可以并排安装,因此您可以在不同版本之间切换(如果已安装)。
如果 PowerShell [Core] 版本安装在非标准位置,因此未自动发现,您可以通过 settings.json 告诉 PowerShell 扩展在哪里找到它,如链接主题和 @ 的底部部分所示987654327@.
右下角的状态栏显示正在使用的 PowerShell 版本(版本 >= 6 表示 PowerShell [Core];您可以单击版本号切换到不同的版本);例如:
[+] 从 v7.0 开始;时间会证明 PowerShell [Core] 是否会随 Windows 的未来版本甚至其他平台一起提供。
[*] 来自linked docs:“此功能查看不同操作系统上的一些众所周知的路径,以发现 PowerShell 的安装位置。如果您将 PowerShell 安装到非典型位置,它可能最初不会出现在会话菜单中。您可以通过 adding your own custom paths 扩展会话菜单。”如果您使用official installers 之一,PowerShell 扩展应该会找到您的安装。
【讨论】: