vscode-code-runner icon indicating copy to clipboard operation
vscode-code-runner copied to clipboard

How to run task in tasks.json

Open Yensan opened this issue 7 years ago • 5 comments

I write some C code, if I want to run the code, must compile files or make the project. So, I write the tasks.json. But, how to use task.json and set these dependsOn task in settings.json for code-runner?

{"label": "VC_Compile", "group": "build", "windows": {"command": "call", "args": [""C:/Program Files (x86)/Microsoft Visual C++ Build Tools/vcbuildtools.bat"", "X86", "&& cd /d ${workspaceRoot}", "&& cl /W4 /EHsc /Ox /GL /source-charset:utf-8 /DNDEBUG /MT", "-IC:/Python3632/include", "/Fd:out/ /Fo:out/ ${file}", "/link", "/LIBPATH:C:/Python3632/libs /LIBPATH:C:/Python3632/PCbuild/win32", "/out:out/${fileBasenameNoExtension}.out"]}, "type": "shell", "problemMatcher": ["$tsc"], "dependsOn": "clear_o_files", "presentation": {"echo": true, "reveal": "always", "focus": false, "panel": "shared"} },

Yensan avatar Dec 07 '17 11:12 Yensan

Hi @Yensan , Code Runner has no relation to the tasks.json, what you need is to update code-runner.executorMap, https://github.com/formulahendry/vscode-code-runner#configuration

"code-runner.executorMap": {
        "c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt && balabalala"
    }

formulahendry avatar Dec 07 '17 12:12 formulahendry

Hi, @formulahendry , thank you for answer. I know, but I want to relate them. Because compile/build is a complex task, it is not so convenient to write in code-runner.executorMap, because it is just One Line to write! :laughing:

Yensan avatar Dec 07 '17 12:12 Yensan

I am also curious about this feature, and i think it is useful. I think maybe this can be realized by calling the task APIs of VS: https://github.com/Microsoft/vscode/issues/45980 ?

siyueyinghua avatar Dec 15 '20 05:12 siyueyinghua

A good solution to this would be to run the task with the code command from settings.json but it looks like the code command can't run tasks

user-name-is-taken avatar Dec 15 '20 17:12 user-name-is-taken

So it is not possible to run a task from code-runner.executormap? Or at least be able to show the tasks in the context menu of the editor?

chiqui3d avatar May 02 '22 16:05 chiqui3d