Visual studio code 任务-具有多个命令的Windows命令任务

Visual studio code 任务-具有多个命令的Windows命令任务,visual-studio-code,Visual Studio Code,尝试运行在windows命令shell中运行的make任务时出现问题。我尝试了各种组合,但无法使命令完全执行 在下面的tasks.json中,您可以看到我尝试了各种方法(这种格式提供了最多信息),但在所有尝试中,make file命令都失败了“'make'不被识别为内部或外部命令、可操作程序或批处理文件”。然而,设置make路径的第一个命令中的脚本setCmdEnv等。 前两个命令工作正常,我不明白为什么最后一个命令不能正确执行。 奇怪的是,我可以在shell加载后(出错后)键入make,并且一

尝试运行在windows命令shell中运行的make任务时出现问题。我尝试了各种组合,但无法使命令完全执行

在下面的tasks.json中,您可以看到我尝试了各种方法(这种格式提供了最多信息),但在所有尝试中,make file命令都失败了“'make'不被识别为内部或外部命令、可操作程序或批处理文件”。然而,设置make路径的第一个命令中的脚本setCmdEnv等。 前两个命令工作正常,我不明白为什么最后一个命令不能正确执行。 奇怪的是,我可以在shell加载后(出错后)键入make,并且一切正常

{
"version": "2.0.0",
"type":"shell",
"windows": {
    "options": {
        "shell": {
//          "executable": "C:\\WINDOWS\\System32\\cmd.exe",
            "executable": "",
//          "args": [
//          "/K .\\BuildEnv\\xBuildEnv\\setCmdEnv && cd .\\app && "
//                ]
        }
    }
},
"presentation": {
    "echo": true,
    "reveal": "always",
    "focus": false,
    "panel": "shared",
    "clear": false
},
"tasks": [
    {
        "label": "Make %1.test",
        "command": "cmd.exe",
        "args": [
            " /K .\\BuildEnv\\xBuildEnv\\setCmdEnv && cd .\\app &&        make ${fileBasenameNoExtension}.test"
        ],
        "problemMatcher": []
    }
],
}

我有一个类似的问题,为了让VisualStudio代码任务执行多个命令,我必须分离args数组的每个元素以省去任何空白。所以在这种情况下,任务可能是这样的:

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "Make your test file",
      "type": "shell",
      "windows": {
        "command": "%comspec%",
        "args": ["/C", "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\Tools\\VsDevCmd.bat", 
                 "&&", "cd", ".\\apps", "&&", "make", "${fileBasenameNoExtension}.test"
        ]
      },
      "options": {
        "cwd": "${workspaceRoot}"
      },
      "presentation": {
        "showReuseMessage": false,
        "reveal": "always",
        "panel": "shared",
        "group": "test",
        "clear": true,
        "focus": true
      }
    }
  ]
}

注意:变量
%comspec%
解析为
C:\WINDOWS\system32\cmd.exe
我遇到了类似的问题,为了使Visual Studio代码任务执行多个命令,我必须分离
args
数组的每个元素以省去任何空白。所以在这种情况下,任务可能是这样的:

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "Make your test file",
      "type": "shell",
      "windows": {
        "command": "%comspec%",
        "args": ["/C", "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\Tools\\VsDevCmd.bat", 
                 "&&", "cd", ".\\apps", "&&", "make", "${fileBasenameNoExtension}.test"
        ]
      },
      "options": {
        "cwd": "${workspaceRoot}"
      },
      "presentation": {
        "showReuseMessage": false,
        "reveal": "always",
        "panel": "shared",
        "group": "test",
        "clear": true,
        "focus": true
      }
    }
  ]
}
注意
%comspec%
变量解析为
C:\WINDOWS\system32\cmd.exe