如何在Visual Studio代码中为MSVC生成的文件创建输出文件夹?

发布于 2025-01-25 15:58:01 字数 1298 浏览 1 评论 0原文

我正在关注教程在这里工作室代码。

一切运行顺利。唯一的问题是自动生成的文件(.lnk,.pdb,.exe和theeles)在我的SRC本身中生成。如何获得生成输出文件夹并存储自动生成文件的任务?

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
        }
      }
    ]
  }

启动。

{
    "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"
      }
    ]
  }

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"
      }
    ]
  }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文