Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

To configure Visual Studio Code to debug C# scripts on OSX, I followed through all the steps listed in the article below:

Debugging C# on OSX with Visual Studio Code

When I tried to debug the sample C# script, Visual Studio Code reported this error:

Could not find the preLaunch task 'build'

As a consequence, I could not inspect the variables defined in the script.

This is a copy of the launch.json file:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch console application",
            "type": "mono",
            "request": "launch",
            "preLaunchTask": "build",
            "program": "${workspaceRoot}/Program.exe",
            "args": [],
            "cwd": "${workspaceRoot}",
            "stopAtEntry": false
        }
    ]
}

This is a copy of the tasks.json file:

{
    "version": "0.1.0",
    "command": "mcs",
    "args": [
        "-debug",
        "Program.cs"
    ],  
    "showOutput": "silent",
    "taskSelector": "/t:",
    "tasks": [
        {
            "taskName": "exe",
            "isBuildCommand": true,
            "problemMatcher": "$msCompile"
        }
    ]
}

How do I resolve this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
314 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...