admin管理员组文章数量:1353111
This is offshoot of How to define variables in global options in vscode tasks.json and refer it in task?
We use some custom build system (not vanilla make). Generally, we don't build code (C++) in the sandbox and create linked area (directory with soft links to files in the sandbox) to do the build there. For debug and optimized builds, I may have 2 such paths. And I want to define 2 different tasks for triggering opt or debug builds ...
To experiment to open build log through tasks, I tried following -
{
"version": "2.0.0",
"options": {
"env": {
"OPT_BUILD_AREA": "<some path>/opt",
"DBG_BUILD_AREA": "<some path>/dbg"
},
},
"tasks": [
{
"label": "Open Full Opt-Build Log",
"type": "shell",
"command": "code",
"args": [
"--reuse-window",
"--goto",
"${OPT_BUILD_AREA}/build.log"
],
"presentation": {
"reveal": "silent",
"focus": true,
"panel": "shared"
},
},
{
"label": "Test Full Opt-Build Log Path",
"type": "shell",
"command": "echo",
"args": ["${OPT_BUILD_AREA}/build.log"]
}
]
}
However, this always opens the log in new window. How to open it in a new table of existing window?
I have already tried following but does nothing
"command": "${command:workbench.action.quickOpen}",
"args": ["${env:OPT_BUILD_AREA}/build.log"],
Also, what happens, say, if the file does not exist - could my vscode session crash? And if my build command is "build", how can I trigger "build" and open the log from the same task?
This is offshoot of How to define variables in global options in vscode tasks.json and refer it in task?
We use some custom build system (not vanilla make). Generally, we don't build code (C++) in the sandbox and create linked area (directory with soft links to files in the sandbox) to do the build there. For debug and optimized builds, I may have 2 such paths. And I want to define 2 different tasks for triggering opt or debug builds ...
To experiment to open build log through tasks, I tried following -
{
"version": "2.0.0",
"options": {
"env": {
"OPT_BUILD_AREA": "<some path>/opt",
"DBG_BUILD_AREA": "<some path>/dbg"
},
},
"tasks": [
{
"label": "Open Full Opt-Build Log",
"type": "shell",
"command": "code",
"args": [
"--reuse-window",
"--goto",
"${OPT_BUILD_AREA}/build.log"
],
"presentation": {
"reveal": "silent",
"focus": true,
"panel": "shared"
},
},
{
"label": "Test Full Opt-Build Log Path",
"type": "shell",
"command": "echo",
"args": ["${OPT_BUILD_AREA}/build.log"]
}
]
}
However, this always opens the log in new window. How to open it in a new table of existing window?
I have already tried following but does nothing
"command": "${command:workbench.action.quickOpen}",
"args": ["${env:OPT_BUILD_AREA}/build.log"],
Also, what happens, say, if the file does not exist - could my vscode session crash? And if my build command is "build", how can I trigger "build" and open the log from the same task?
Share Improve this question asked Apr 2 at 6:14 soumeng78soumeng78 88210 silver badges22 bronze badges1 Answer
Reset to default 0It works fine for me if I just switch the task type from shell
to process
. You don't need a shell type anyway.
Also, your environment variable reference should be of the form ${env:FOO}
. You seem to know this but don't apply it consistently.
Also, as you should already know from your other question, and as the docs say:
Environment variables configured [in
options
] can only be referenced from within your task script or process and will not be resolved if they are part of your args, command, or other task attributes.
So your environment variable reference in args
just evaluates to nothing.
版权声明:本文标题:visual studio code - How to open log file through task in new tab of existing vscode window? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743856677a2550982.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论