Could not find the preLaunch task 'build'

It seems like this will be different for every scenario.

For me what @Jeferson Tenorio worked, but it needed a few more steps so let's add them:

  1. Click on Configure Task: enter image description here
  2. Create tasks.json file from template
  3. .NET Core Executes .NET Core build commands
  4. Go to your launch.json file, and under configurations/program you will find this:

    ${workspaceFolder}/bin/Debug/<insert-target-framework-here>/<insert-project-name-here>.dll

    Simply replace <insert-target-framework-here> and <insert-project-name-here> with your target framework, in my case that would be netcoreapp2.0 and then your project name (if you haven't changed anything your project name should be the same as the folder where you created your project), it should look something like this:

    "program": "${workspaceFolder}/bin/Debug/netcoreapp2.0/MyProject.dll"

    I hope this helps.


The error occurs because Visual Studio Code cannot find any task in the tasks.json with the taskName value set to 'build'.

The preLaunchTask property of the launch.json file defines the task that should be executed before the script is launched. From the question, Visual Studio Code has been configured to run the task build before launching the script:

preLaunchTask: 'build'

But there's no task named 'build' in the tasks.json file.

To fix this, you should change the value of the preLaunchTask property to 'exe', which is the build task that has been defined in the tasks.json file.


You can use the Visual Studio Code to solve it.

When you see the error message, click on the steps below error sample

  1. Configure Task
  2. Create tasks.json file from template
  3. NET Core Executes .NET Core build commands

The VSCode will create a file like it:

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build",
            "command": "dotnet build",
            "type": "shell",
            "group": "build",
            "presentation": {
                "reveal": "silent"
            },
            "problemMatcher": "$msCompile"
        }
    ]
}

It's finished. The VSCode will build the project before run.