如何在launch.json中配置vs代码工作目录

时间:2017-11-28 20:44:17

标签: visual-studio-code

我使用goland(与webstorm / intellij等相同)IDE,在调试配置中有一个地方,你可以配置working directory现在我尝试使用VSCODE并且我没有找到这个配置,经过一些研究我发现以下json应该处理这个但是找不到工作目录的正确位置

e.g。这是我的工作目录

/Users/i022226/go/src/myapp

"configurations": [{
            "name": "Launch Package",
            "type": "go",
            "request": "launch",
            "mode": "debug",
            "program": "${workspaceRoot}"
        },
        {
            "name": "Launch Package",
            "type": "go",
            "request": "launch",
            "mode": "debug",
            "program": "${workspaceRoot}"
        },
        {
            "name": "Launch",
            "type": "go",
            "request": "launch",
            "mode": "debug",
            "remotePath": "",
            "port": 2345,
            "host": "127.0.0.1",
            "program": "${fileDirname}",
            "env": {},
            "args": [],
            "showLog": true
        } 

launch.json中有添加配置按钮,当我输入cwd时,我没有任何条目,任何想法?

在这篇文章中,cwd位于option下,但我找不到option https://github.com/Microsoft/vscode/issues/856

2 个答案:

答案 0 :(得分:2)

您应该像以下

一样添加它
@store_chromosomes

答案 1 :(得分:2)

下面是一个示例launch.json,该示例在基于Tals's answer的项目子文件夹中运行Python模块:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Launch",
            "type": "python",
            "request": "launch",
            "module": "module_source_folder.filename",
            "cwd": "${workspaceFolder}/examples/folder_with_test_files",
            "args": ["-f", "input_filename"]
        }
    ]
}

请注意,cwd必须位于args之前,否则它将无法正常工作。