如何在VS Code launch.json中创建用户定义的变量?

时间:2019-12-16 20:33:05

标签: visual-studio-code

我有以下VS代码launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "My API",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build",
            "program": "${workspaceFolder}/MyProject/bin/Debug/netcoreapp3.0/MyProject.dll",
            "args": [],
            "cwd": "${workspaceFolder}/MyProject.csproj",                
        }
    ]
}

我想创建一个局部变量,并使用它来避免重复某些值并使更容易频繁地更改此特定值。

我试图通过环境变量创建此局部变量,但是env变量值未在字段中设置:

{
    "version": "0.2.0",
    "options": {
        "env": {
            "MY_PROJECT": "MyProject"
        }
    },
    "configurations": [
        {
            "name": "My API",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build",
            "program": "${workspaceFolder}/${env:MY_PROJECT}/bin/Debug/netcoreapp3.0/${env:MY_PROJECT}.dll",
            "args": [],
            "cwd": "${workspaceFolder}/${env:MY_PROJECT}.csproj",                
        }
    ]
}

0 个答案:

没有答案