I've created a custom task that opens Google-Chrome with the currently opened file. This works great, but I can't seem to find a way to suppress the output in the terminal.
Trying the suggestion on the site doesn't help either.
Tasks.json
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"taskName": "Open in browser",
"command": "google-chrome",
"type": "process",
"args": ["${file}"],
"presentation": {
"reveal": "never",
"echo": false
},
"problemMatcher": []
}
]
}
The output is always visible in the Terminal:
Is there a way to have no output at all?
Related
I have recently discovered that there a gms extension in visual studio code so you can write your GAMS code there. The description of the extension says following:
Provides syntax highlighting for .gms and .inc files and shortcuts for running GAMS models
I wonder if it is possible to actually run your GAMS code from Visual Studio Code?
Yes. You have to do this from the terminal.
You can set up a default build task (shown below) for the current opened file (${fileBasename}) and run with ctrl+shift+b. It's possible to add arguments to the "args" array, i.e. gdx=default etc.
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Run this file with GAMS",
"type": "shell",
"command": "gams",
"args": [
"${fileBasename}"
],
"group": {
"kind": "build",
"isDefault": true
},
"options": {
"env": {
"PATH": "/opt/gams:${env:PATH}"
}
}
}
]
}
In such a way that it is not in a sub shell. I need it to be able to prepare the environment...set environment variable.
"version": "0.1.0",
"command": "${workspaceFolder}/Invoke-Task.ps1",
/*"command": "powershell", creates subshell so doesn't work*/
"isShellCommand": false,
"args": [],
"showOutput": "always",
"echoCommand": true,
"suppressTaskName": true,
"tasks": [
{
"taskName": "task1",
"args": ["task1"]
},
{
"taskName": "task2",
"args": ["task2"]
}
]
I am sorry, but you are not correctly editing the .vscode/tasks.json file.
In your scenario, lets say you have some powershell script ./scripts/mycustomPSscript.ps1 you want to run as a vscode task. For such goal, edit the tasks file so it follows the below example:
{
"version": "2.0.0",
"tasks": [
{
"label": "Run-some-custom-script",
"detail": "Prepare some ENV variables for the deployment",
"type": "shell",
"command": "./../scripts/mycustomPSscript.ps1",
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared",
"showReuseMessage": true,
"clear": false
}
}
]
}
This has been doable since 2017, if I get your ask correctly.
integrated-terminal-tasks README This extension allows a workspace to
define specific tasks that should be ran in VSCode's interactive
terminal
https://marketplace.visualstudio.com/items?itemName=ntc.integrated-terminal-tasks
Also, your post / query, could been seen as a duplicate of this...
Run Code on integrated terminal Visual Studio Code
Adding this configuration in the launch.json file did the trick for me
"version": "0.2.0",
"configurations": [
{
"type": "PowerShell",
"request": "launch",
"name": "PowerShell Launch Current File",
"script": "put full path here\\launch.ps1",
"args": ["${file}"],
"cwd": "${file}"
},...
Not sure what you mean by 'integrated terminal' but the output does show up in the VSC terminal if this is what you're referring to.
Is it possible to run a task from a task in VSCode?
Example json:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"taskName": "Show In Chrome",
"windows": {
"command": "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"
},
"osx": {
"command": "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
},
"args": [
"${file}"
],
"type": "process",
},
{
"taskName": "Show Coverage",
// this is the task to call another task
}
]
}
What i would like to do is have the Show Coverage task look for a file in the coverage folder and then call Show In Chrome task to show it as the arguments of that file being passed. Is this possible?
It turns out the current config from the docs website isn't updated for tasks.
However if you want a task to call other tasks because it depends on them you can simply add this configuration
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"taskName": "Show In Chrome",
"identifier": "showInChrome",
"windows": {
"command": "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"
},
"osx": {
"command": "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
},
"args": [
"${file}"
],
"type": "process",
},
{
"taskName": "Show Coverage",
"dependsOn": "showInChrome"
}
]
}
this will cause the task to run the previous task and then run whatever commands it has set as well.
Note: you can use multiple depends by using an array of identifiers.
My tasks.json looks like this:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
// A task runner that runs a python program
"command": "python3",
"presentation": {
"echo": true,
"reveal": "always",
"focus": true
},
"args": [
"${file}"
]
}
When I run ctrl+shift+B the top panel asks "Select the build task to run", and there's one alternative: python3. Now if I'd like to add a new build-task (for example a runspider command with scrapy), so it's added to the build tasks. How would I go about adding this?
You can define multiple tasks in your tasks.json by assigning an array of task objects to the tasks property, like this:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"taskName": "python3",
"type": "shell",
"command": "python3",
"args": [
"${file}"
],
"presentation": {
"echo": true,
"reveal": "always",
"focus": true
}
},
{
"taskName": "runspider",
"type": "shell",
"command": "runspider"
}
]
}
Also, Ctrl+Shift+B runs the default build task, so you might want to set your "workbench.action.tasks.runTask" keybinding.
{
"key": "ctrl+shift+b",
"command": "workbench.action.tasks.runTask"
}
Once that is done, you can select the task when you use workbench.action.tasks.runTask command, as shown below:
You can also choose your default build task by setting the "group" property on the task. Here, in the following snippet, your "python3" task will run as the default build task.
...
"tasks": [
{
"taskName": "python3",
"type": "shell",
"command": "python3",
"args": [
"${file}"
],
"presentation": {
"echo": true,
"reveal": "always",
"focus": true
},
"group": {
"kind": "build",
"isDefault": true
}
},
{
"taskName": "runspider",
"type": "shell",
"command": "runspider"
}
]
...
You can read more about tasks here: Tasks in VSCode
In Visual Studio Code, I have the following build task (tasks.json) set up and it was working until today.
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "tsc",
"isShellCommand": true,
"args": ["-p", "."],
"showOutput": "always",
"problemMatcher": "$tsc"
}
I did upgrade VSCode to 1.12.1 so I'm wondering if that upgrade is why this is no longer working. Basically now when I hit Ctrl Shift B, nothing happens. Usually a spinning icon displays at the bottom and then errors display in the task output. Now nothing occurs. I can still build on the command successfully (tsc -p .)
Here is how I configured my VS Code:
tasks.json
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "python",
"group": {
"kind": "build",
"isDefault": true
},
"args": [
"setup.py",
"install"
],
"presentation": {
"echo": true,
"panel": "shared",
"focus": true
}
}
]
}
The issue went away after I upgraded my Visual Studio Team Services extension.