首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在Visual代码中指定Powershell 7的新方法?

在Visual代码中指定Powershell 7的新方法?
EN

Stack Overflow用户
提问于 2022-09-25 14:24:17
回答 1查看 221关注 0票数 2

我试图在Windows 11上用更新的Powershell 7替换默认的Powershell 5。

互联网上99%的解决方案说要把这个添加到settings.json中。

代码语言:javascript
运行
复制
"terminal.integrated.shell.windows": "C:\\Program Files\\PowerShell\\7\\pwsh.exe"

但是,这现在给出了一条红色的、带有以下信息的行:

这是不可取的,配置默认shell的新方法是在#terminal.integrated.profiles.windows#中创建终端配置文件,并将其配置文件名设置为#terminal.integrated.defaultProfile.windows#中的默认配置文件名。目前,这将优先于新的配置文件设置,但这将在未来发生变化。

有一个可能相关线程,但它只处理将其默认为本机Command Prompt,而不是将内容重新编排到Powershell 7

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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-09-25 17:32:20

在早期的VSCode (Visual )版本中,"terminal.integrated.shell.*""terminal.integrated.shellArgs.*"设置确定了集成终端的默认外壳及其启动参数。

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

代码语言:javascript
运行
复制
"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代码集成终端的默认通用外壳程序。
  • 有关如何指定PowerShell版本与PowerShell扩展附带的专用PIC (PowerShell集成控制台)一起使用的信息(有关编写和调试PowerShell代码),请参见这个答案
  • 我原以为Visual代码会自动使用您的v7版本,因为它--如果安装了--通常优先于PowerShell。
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73845252

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档