admin管理员组

文章数量:1026989

When using vs.code, I have to use a non-standard compiler, and it's easier to just run it from Makefile. I have it set up as a task in tasks.json. I am trying to make my postDebugTask remain in terminal if there is an error. I am trying to do that with my postDebugTask called run_flash.

BUT, if I re-invoke the build or "run" process, I want to terminate all running tasks. I am trying to do this with my preLaunchTask kill_all_tasks.

If I launch another process, it does not kill the previous process.

Really, what I want is for any time my normal task is launched, I want to kill off the previous task. Like is there any sort of task option to say "there can only be one of these tasks"?

Here is the launch configuration from my launch.json

        {
            "name": "Compile and Flash",
            "type": "node",
            "request": "launch",
            "internalConsoleOptions": "neverOpen",
            "preLaunchTask" : "kill_all_tasks",
            "postDebugTask": "run_flash",
            "presentation": {
                "hidden": false,
                "group": "terminaloutput",
                "order": 1
            },
            "runtimeExecutable": "echo"
        }

Here are my tasks:

        {
            "type": "shell",
            "label": "run_flash",
            "command": "make clean closechlink; make flash",
            "presentation": {
                "echo": true,
                "focus": true,
                "group": "build",
                "panel": "shared",
                "close": true,
                "reveal": "always",
                "showReuseMessage": true
            },
            "isBackground": false,
            "options": {
                "cwd": "${workspaceFolder}",
            },
            "runOptions": {
                "instanceLimit": 1,
            },
            "group": "build",
            "problemMatcher": { // 
                "owner": "cpp",
                "fileLocation": [
                    "relative",
                    "${workspaceFolder}"
                ],
                "pattern": {
                    "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
                    "file": 1,
                    "line": 2,
                    "column": 3,
                    "severity": 4,
                    "message": 5
                },
            }
        },
        {
            "type": "process",
            "label" : "kill_all_tasks",
            "command":[
                "${command:workbench.action.tasks.terminate}  terminateAll",
            ]
        }

When using vs.code, I have to use a non-standard compiler, and it's easier to just run it from Makefile. I have it set up as a task in tasks.json. I am trying to make my postDebugTask remain in terminal if there is an error. I am trying to do that with my postDebugTask called run_flash.

BUT, if I re-invoke the build or "run" process, I want to terminate all running tasks. I am trying to do this with my preLaunchTask kill_all_tasks.

If I launch another process, it does not kill the previous process.

Really, what I want is for any time my normal task is launched, I want to kill off the previous task. Like is there any sort of task option to say "there can only be one of these tasks"?

Here is the launch configuration from my launch.json

        {
            "name": "Compile and Flash",
            "type": "node",
            "request": "launch",
            "internalConsoleOptions": "neverOpen",
            "preLaunchTask" : "kill_all_tasks",
            "postDebugTask": "run_flash",
            "presentation": {
                "hidden": false,
                "group": "terminaloutput",
                "order": 1
            },
            "runtimeExecutable": "echo"
        }

Here are my tasks:

        {
            "type": "shell",
            "label": "run_flash",
            "command": "make clean closechlink; make flash",
            "presentation": {
                "echo": true,
                "focus": true,
                "group": "build",
                "panel": "shared",
                "close": true,
                "reveal": "always",
                "showReuseMessage": true
            },
            "isBackground": false,
            "options": {
                "cwd": "${workspaceFolder}",
            },
            "runOptions": {
                "instanceLimit": 1,
            },
            "group": "build",
            "problemMatcher": { // 
                "owner": "cpp",
                "fileLocation": [
                    "relative",
                    "${workspaceFolder}"
                ],
                "pattern": {
                    "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
                    "file": 1,
                    "line": 2,
                    "column": 3,
                    "severity": 4,
                    "message": 5
                },
            }
        },
        {
            "type": "process",
            "label" : "kill_all_tasks",
            "command":[
                "${command:workbench.action.tasks.terminate}  terminateAll",
            ]
        }

本文标签: visual studio codeVSCode tasks that automatically kills all other tasks on invokeStack Overflow