【问题标题】:Default Terminal In VS Code WindowsVS Code 窗口中的默认终端
【发布时间】:2021-08-17 21:55:12
【问题描述】:

我已经设置了一段时间以在 VS Code 中运行 C++ 程序。它基本上是一个tasks.json,看起来像这样

"tasks": [
      {
        "label": "Compile and run",
        "type": "shell",
        "command": "",
        "args": [
          "g++",
          "${fileBasename}",
          "-o",
          "test",
          "&&",
           ...
   }

我还保留了一个 settings.json 来定义要使用的终端,即命令提示符, 出于某种原因,在 VS Code 的最新更新中,我的设置变得一团糟,它不再工作了。

我想知道将cmd 定义为运行任务的终端的正确语法,因为&& < > 在powershell 中不起作用

【问题讨论】:

标签: visual-studio-code vscode-settings vscode-tasks


【解决方案1】:

Luuk 发表评论后,我进行了更多挖掘,发现以下内容可以解决我的 vs 代码任务问题。我只需要将&& 更改为;,对于输入输出重定向,我使用了answer。现在我的 tasks.json 看起来像这样

 "tasks": [
      {
        "label": "Compile and run",
        "type": "shell",
        "command": "",
        "args": [
          "g++",
          "${fileBasename}",
          "-o",
          "test",
          ";",
          "cmd",
          "/c",
          "'test.exe < input.txt > output.txt'",
          ";",
          "del",
          "*exe",
          ";",
          "del",
          "${fileBasename}"
        }
]

【讨论】:

    猜你喜欢
    • 2021-11-01
    • 2022-11-05
    • 2021-05-02
    • 1970-01-01
    • 1970-01-01
    • 2022-01-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多