繁体   English   中英

在 Visual Studio Code 中指定 Powershell 7 的新方法?

[英]New way to specify Powershell 7 in Visual Studio Code?

我正在尝试在 Windows 11 上用较新的 Powershell 7 替换默认的 Powershell 5。

互联网上 99% 的解决方案都说要将此添加到settings.json

"terminal.integrated.shell.windows": "C:\\Program Files\\PowerShell\\7\\pwsh.exe"

但是,现在这会给出一条带有以下消息的红色波浪线:

这是不推荐使用的,配置默认 shell 的新推荐方法是在#terminal.integrated.profiles.windows#中创建终端配置文件并将其配置文件名称设置为#terminal.integrated.defaultProfile.windows#中的默认值。 这目前将优先于新的配置文件设置,但将来会改变。(2)

有一个可能相关的线程,但它只处理将其默认为本机Command Prompt ,而不是将事情重新调整为Powershell 7

那么,提供Powershell 7 s 路径到 VS Code 并将其设置为默认终端的正确新方法是什么?

早期的VSCode 版本中, "terminal.integrated.shell.*""terminal.integrated.shellArgs.*"设置决定了集成终端的默认 shell 及其启动 ZDBC11CAA5BDA829F77E6FBDA8278。

这些已被shell配置文件取代,这些配置文件通过"terminal.integrated.profiles.*"属性和关联的"terminal.integrated.defaultProfile.*"属性定义,其中包含默认使用的配置文件的名称,如下所示(使用> Preferences: Open Settings (JSON)从命令面板打开您的settings.json文件):

"terminal.integrated.profiles.windows": {
    "PowerShell_7": {
      "source": "C:\\Program Files\\PowerShell\\7\\pwsh.exe",
      "icon": "terminal-powershell"
    },  // ...
}

// Make the profile defined above the default profile.
"terminal.integrated.defaultProfile.windows": "PowerShell_7" 

笔记:

  • 上面定义了 Visual Studio Code 的集成终端默认的通用shell。

  • 有关如何指定 PowerShell 版本与PowerShell 扩展(用于创作和调试 PowerShell 代码)附带的专用PIC(PowerShell 集成控制台)的信息,请参阅此答案

  • 我本来希望 Visual Studio Code自动使用您的 v7 版本,因为它(如果已安装)通常优先于 Windows PowerShell。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM