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