記一次VSCode調(diào)試Aspnetcore.Doc時遇到的“couldn't find task build”問題

Aspnetcore.Doc是微軟開源的netcoreDemo項目,包括官方文檔中所有的源代碼,是非常好的dotnetcore學習資源,項目地址為https://github.com/aspnet/AspNetCore.Docs

在使用vscode調(diào)試該項目時,首先遇到了如題目所述的問題。vscode調(diào)試時需要launch.json和task.json兩個配置文件,在創(chuàng)建task文件后,問題解決。task文件的內(nèi)容可參考以下代碼:

tasks.json
{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "command": "",
    "args": [],
    "tasks": [
        {
            "label": "build",
            "command": "dotnet",
            "type": "shell",
            "args": [
                "build"
            ],
            "options": {
                "cwd": "${workspaceRoot}"
            },
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "presentation": {
                "echo": true,
                "reveal": "always",
                "focus": false,
                "panel": "shared"
            },
            "problemMatcher": "$msCompile"
        }
    ]
}

注意,{workspaceRoot}是使用vscode的OpenFolder打開的路徑。如果.csproj不在此路徑下,需要手動修改'cwd'的內(nèi)容,以下是我使用的路徑:

 "options": {
        "cwd": "${workspaceRoot}/aspnetcore/fundamentals/servers/kestrel/samples/2.x/KestrelSample"
},

成功后Debug Console中顯示調(diào)試信息,此時可命中斷點

image.png
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容