microsoft / microsoft/vscode-cpptools

Microsoft C++ configure "Run VS Code outside the Developer Command Prompt" doesn't work

Open
#11,811 13 comments 6 reactions 1 assignee View on GitHub

@AlexandraKemperMS is already working on this.

Since Dec 8, 2023.

transferred-from-docs
Dominant language
TypeScript
Stars
6.2k
Forks
1.7k
Avg merge
14h 46m
Merged PRs (30d)
61

Description

Does this issue occur when all extensions are disabled?: Yes/No

  • VS Code Version: 1.85.0
  • OS Version: Windows 11 Home, version 23H2 Build 22631.2715

I followed the exact guide in https://code.visualstudio.com/docs/cpp/config-msvc#_run-vs-code-outside-the-developer-command-prompt

But my code only works when I start VSC with Developer Command Prompt. When I start VSC from a shortcut, it gives error cl.exe is not recognized.... Even when I modified the task's command. Here's my tasks.json:

{
    "version": "2.0.0",
    "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 (x86)/Microsoft Visual Studio/2022/BuildTools/Common7/Tools/VsDevCmd.bat\"",
            "&&"
            ]
        }
        }
    },
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: cl.exe build active file",
            "command": "C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.38.33130/bin/Hostx86/x86/cl.exe",
            "args": [
                "/Zi",
                "/EHsc",
                "/nologo",
                "/Fe${fileDirname}\\${fileBasenameNoExtension}.exe",
                "${file}"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$msCompile"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "Task generated by Debugger."
        }
    ]
}

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.