找不到preLaunch任务"build" [英] Could not find the preLaunch task 'build'

查看:760
本文介绍了找不到preLaunch任务"build"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要配置Visual Studio Code在OSX上调试C#脚本,我按照下面文章中列出的所有步骤进行操作:

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

在Visual Studio上的OSX上调试C# Studio代码

当我尝试调试示例C#脚本时,Visual Studio Code报告了此错误:

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

找不到预启动任务"build"

Could not find the preLaunch task 'build'

结果,我无法检查脚本中定义的变量.

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

这是 launch.json 文件的副本:

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

这是 tasks.json 文件的副本:

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

我该如何解决?

推荐答案

您可以使用Visual Studio代码来解决它.

You can use the Visual Studio Code to solve it.

当您看到错误消息时,请单击以下步骤

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

  1. 配置任务
  2. 从模板创建task.json文件
  3. NET Core执行.NET Core构建命令

VSCode将创建一个类似的文件:

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"
        }
    ]
}

完成了. VSCode将在运行之前构建项目.

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

这篇关于找不到preLaunch任务"build"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆