Nick
Nick

Reputation: 9061

Where is the tasks.json file in vscode?

I just start to use vscode in linux. I know that the build configuration are set in tasks.json. But where does this file locate?

I tried Ctrl-Shift-P then

tasks, no commands matching.

build, no commands matching.

I also tried to find it in ~/.vscode folder, nothing here!

Is there a way to find / open this file?

Upvotes: 48

Views: 106414

Answers (5)

Steffen
Steffen

Reputation: 3516

  1. Open a folder with vscode
  2. Hit F1
  3. Select "Tasks: Configure Task"
  4. Hit Enter and vscode will create a sample tasks.json for you

enter image description here

Upvotes: 65

Dhanya Gopinath
Dhanya Gopinath

Reputation: 137

Add C# extension from Microsoft. Post that open any cs file. It will install C# dependencies.The you will get a pop up

enter image description here

Click yes. Both tasks.json and launch .json are created.

Upvotes: 1

PhillipJacobs
PhillipJacobs

Reputation: 2490


2019 Version

New tasks version 2.0.0

Here's how to do it step by step


I compiled this from the documentation:

First i tried ā¬†ļøŽ āŒ˜ B ... This didn't work for me (I was following a YouTube tutorial... a bit outdated it seems).

After looking at the documetation i found that you have to initialize your typescript folder. To do so:

tsc --init - this will generate a file called tsconfig.json

The documentation said to run code . after you ran tsc --init. Mine worked without is as well as with it. Feel free to play with it and see what it changes cause i honestly don't know.

After that, move your mouse up to the toolbar (global Terminal menu.)... underneath the Terminal tab, click on the Configure Default Build Task...

then click on tsc: build and that will generate your tasks.json

Note that mine generated without the "version": "2.0.0" line... so if yours did the same that means your hardware is too old and you have to upgrade.... i'm kidding! ... Just add "version": "2.0.0", right above "tasks": [, and then you should be fine.

āœŒšŸ½

Upvotes: 8

breakpoint
breakpoint

Reputation: 986

DANGER! All of this has changed. Current Microsoft docs on this topic are NOT consistent. Note the version warning at the top of this:

https://code.visualstudio.com/docs/editor/tasks

Note the conflicts between this:

https://learn.microsoft.com/en-us/visualstudio/ide/customize-build-and-debug-tasks-in-visual-studio?view=vs-2017

and this:

https://code.visualstudio.com/docs/languages/cpp

I cannot get a straight answer on what works now (12MAR2019) to save my life, but I can tell you that none of the permutations I've tried, namely:

{., .vs, .vscode} / { tasks.json, tasks.vs.json}

are working for me. It really drives me crazy that they changed this crap without updating ALL of the pertinent documentation, and the backward-compatibility "support" is just making things MUCH WORSE.

Upvotes: 21

s.d
s.d

Reputation: 29436

You have to create it manually. Current version of VS Code only creates launch.json automatically. The auto detect claims made in docs also don't work (for me at least).

Here is a sample file you can create in .vscode/tasks.json that defines gulpjs tasks:

{
    "version":"0.1.0",
    "command": "./node_modules/.bin/gulp",
    "isShellCommand": true,
    "tasks":[
        {
            "taskName": "test",
            "isTestCommand": true,
            "problemMatcher": "$gulp-tsc",
            "showOutput": "always"
        }
    ]
}

Upvotes: 6

Related Questions