Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSCode build not working - No build task defined. Mark a task with 'isBuildCommand' in the tasks.json file

I have fresh install of VSCode, and this tiny basic TypeScript app.

First time, when I want to build the app, VScode needs to generate tasks.json.

And it worked long time ago before.

Today I am getting this weird message

No build task defined. Mark a task with 'isBuildCommand' in the tasks.json file.

I don't remember seeing this message before.

enter image description here

But, OK, I click Configure Build Task, select TypeScript task, and tasks.json gets generated.

enter image description here

But, what happens, after I try to build now, Ctrl+Shift+B, and I get the exact same message again

enter image description here

Any ideas? Thanks.

BTW, adding this setting to tasks.json doesnt solve the problem.

enter image description here

like image 356
monstro Avatar asked Apr 15 '17 12:04

monstro


People also ask

What is task json in VS Code?

Tasks in VS Code can be configured to run scripts and start processes so that many of these existing tools can be used from within VS Code without having to enter a command line or write new code. Workspace or folder specific tasks are configured from the tasks. json file in the . vscode folder for a workspace.

Where Is tasks json located?

json files are located in a hidden folder called . vs in the root folder of your codebase. The tasks.

What is task json?

tasks. json is used to execute anything else you may want, be that source code formatters, bundlers or a SASS compiler. To use a configuration from tasks. json , you select Run Task from the command list.


4 Answers

This issue was also adressed here: https://github.com/Microsoft/vscode/issues/24796

It says:

Closing and reopening the window (without starting Code) resolves this issue.

like image 84
misterkugelblitz Avatar answered Oct 16 '22 19:10

misterkugelblitz


Closing and reopening the window

Which window? Closing and reopening the tasks.json window didn't work for me (in VS Code 1.11.2).

Here's what did though:

  • Closing and re-opening Visual Studio Code
  • Ctrl-Shift-B (or your build shortcut)
like image 29
Artie Leech Avatar answered Oct 16 '22 21:10

Artie Leech


In my case, my tasks.json had some nonsense in it. Instead of the "command" property, I wrongly named it "executable"...*

So consider if:

  1. Your JSON is valid syntactically (see screenshot below)
  2. Your JSON is valid according to what VS Code expects

Syntactically invalid: syntactically invalid JSON (for example with a property, followed by a colon, but no value... will cause this issue

Schematically invalid:even if JSON is syntactically valid, it may not meet the expectations for the schema of tasks.json

And while I think the other answers are probably correct (I can't reproduce so I can't verify; the issue has been fixed...), I think when the comment said ...

Closing and reopening the window (without starting Code)

... it may have meant the Reload Window command.


*I wrongly named the tasks.json property "executable", vs "command" because...

  1. I thought "command" was causing issues (it wasn't)
  2. I wanted to run a specific executable in a specific directory like "C:/somewhere/python.exe"; ("command" can do that).

I don't know why I thought "executable" was valid! I thought I was referencing some example, but can't find it... :) )

like image 32
The Red Pea Avatar answered Oct 16 '22 20:10

The Red Pea


[As of 18th September 2021] and VS Code version: 1.60.0

For me, it turned out to be that I wasn't having "isBuildCommand": true.

I understand that this post already assumes that isBuildCommand is already included. But VS Code didn't include this by default for me and being new to VS code if I reached this page, it might be helpful to someone else who is new.

I wanted to have two configurations - Debug and Release. This is how my two configs looks -

{
    "label": "build Debug",
    "command": "dotnet",
    "type": "process",
    "isBuildCommand": true,
    "args": [
        "build",
        "${workspaceFolder}/ABCD/ABCD.csproj",
        "/property:GenerateFullPaths=true",
        "/consoleloggerparameters:NoSummary"
    ],
    "problemMatcher": "$msCompile"
},
{
    "label": "build Release",
    "command": "dotnet",
    "type": "process",
    "isBuildCommand": true,
    "args": [
        "build",
        "${workspaceFolder}/ABCD/ABCD.csproj",
        "/property:GenerateFullPaths=true",
        "/consoleloggerparameters:NoSummary",
        "-c",
        "Release"
    ],
    "problemMatcher": "$msCompile"
}
like image 40
Koder101 Avatar answered Oct 16 '22 19:10

Koder101