Home Articles

无法在VSCode中添加.NET Core tasks.json

Asked
Viewed 1512 times
0

我从控制台创建了一个带有Angular的ASP.NET Core应用程序(dotnet new angular命令) . 我想在Visual Studio Code中为此应用程序启用调试 . 我转到Debug选项卡,单击cog并从.NET Core模板创建launch.json文件 . 如果按F5进行调试,则会出现错误“无法找到preLaunchTask'构建'” . 在Internet上,我读到我应该按Configure Task按钮,然后选择.NET Core选项来创建正确的tasks.json文件,但是缺少此选项,只有npm和tsc的选项 . 我该如何解决这个问题?角模板有可能吗?

1 Answer

  • 0

    以下是.NET Core 2.0的用途:

    • 检查您是否拥有.NET Core SDK 2.0或更高版本

    • 检查您是否有来自VS Code的C#扩展名 . 如果没有install from marketplace

    • 安装节点

    • 使用'dotnet new angular'创建项目

    • 如果VSCode没有't done that already. File should be located in same folder as launch.json (it should be ' .vscode'文件夹,则创建tasks.json文件)
      enter image description here

    • 内容 tasks.json

    {
        "version": "2.0.0",
        "tasks": [
            {
                "type": "npm",
                "script": "install",
                "problemMatcher": []
            },
            {
                "taskName": "build",
                "command": "dotnet",
                "args": [
                "build"
                ],
                "options": {
                    "cwd": "${workspaceRoot}"
                    },
                    "isBuildCommand": true,
                    "showOutput": "always",
                    "problemMatcher": "$msCompile"
                    }
        ]
    }
    
    • 运行调试!

Related