How do I create output folder for MSVC generated files in Visual Studio Code?

224 Views Asked by At

I am following the tutorial here which shows how to use the VS C++ in Visual Studio Code.

Everything runs smoothly. The only problem is the auto-generated files (.lnk, .pdb, .exe and the likes) get generated in my src itself. How do I get the task to generate an output folder and store the auto-generated files there?

tasks.json:

{
    "version": "2.0.0",
    "tasks": [
      {
        "type": "shell",
        "label": "cl.exe build active file",
        "command": "cl.exe",
        "args": [
          "/Zi",
          "/EHsc",
          "/Fe:",
          "${fileDirname}\\${fileBasenameNoExtension}.exe",
          "${file}"
        ],
        "problemMatcher": ["$msCompile"],
        "group": {
          "kind": "build",
          "isDefault": true
        }
      }
    ]
  }

launch.json:

{
    "version": "0.2.0",
    "configurations": [
      {
        "name": "cl.exe build and debug active file",
        "type": "cppvsdbg",
        "request": "launch",
        "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
        "args": [],
        "stopAtEntry": false,
        "cwd": "${workspaceFolder}",
        "environment": [],
        "externalConsole": false,
        "preLaunchTask": "cl.exe build active file"
      }
    ]
  }
0

There are 0 best solutions below