microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.4k stars 1.51k forks source link

Have trouble when Run VS Code outside the Developer Command Prompt #12409

Open mind-dance opened 2 weeks ago

mind-dance commented 2 weeks ago

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

mind-dance commented 2 weeks ago

follow instructions run-vs-code-outside-the-developer-command-prompt, it's basically a copy and paste, except for modifying the path to the .bat file a bit

mind-dance commented 1 week ago

Do I need to provide additional information?

bobbrow commented 1 week ago

@sean-mcmanus, @Colengms is this issue known?

sean-mcmanus commented 1 week ago

It sounds related to the "cppbuild" task type. It's not picking up the environment set in the other shell setting. It's not a known issue that I've seen.