microsoft / microsoft/vscode-cpptools

Have trouble when Run VS Code outside the Developer Command Prompt

Open
#12,409 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug tasks/build/debug
Dominant language
TypeScript
Stars
6.2k
Forks
1.7k
Avg merge
14h 46m
Merged PRs (30d)
61

Description

I have set up tasks.json but still can't run VS Code outside the Developer Command Prompt. My tasks.json like this:

{
    "windows": {
        "options": {
          "shell": {
            "executable": "cmd.exe",
            "args": [
              "/C",
              // The path to VsDevCmd.bat depends on the version of Visual Studio you have installed.
              "\"C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/Tools/VsDevCmd.bat\"",
              "&&"
            ]
          }
        }
      },
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: cl.exe 生成活动文件",
            "command": "cl.exe",
            "args": [
                "/Zi",
                "/EHsc",
                "/nologo",
                "/Fe${fileDirname}\\${fileBasenameNoExtension}.exe",
                "${file}"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$msCompile"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "调试器生成的任务。"
        }
    ],
    "version": "2.0.0"
}

when I run code, it still prompt me that I need Developer Command Prompt

error

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the supplied tasks.json configuration outside the Developer Command Prompt and compare the result with the shown error. Trace how the VS Code task invokes cl.exe and VsDevCmd.bat. Done means the configured C/C++ build task runs successfully from VS Code launched outside the Developer Command Prompt.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, vscode
Domain
build-system, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.