参考
https://azure.github.io/aca-dotnet-workshop/aca/13-appendix/01-run-debug-dapr-app-vscode/
c#调试中的问题
在万物皆可调试-dapr篇的文章中,使用daprd来对c#程序进行调试。在使用dependsOn:build属性进行调试的时候,c#程序无法进行调试,所以删除了dependsOn属性,这个可能是daprd的bug。但在这种情况下,一旦修改代码每次调试前都需要运行下dotnet build。具体可参见https://github.com/microsoft/vscode/issues/176718
对此,我也提了一个issue,https://github.com/microsoft/vscode/issues/181605。
解决办法
虽然执行下dotnet buid也不算麻烦,但是有dependsOn属性,还是应该利用起来,让tasks能按照我们的预期进行执行,修改后的tasks.json如下:
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/新しいフォルダー (2).csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/新しいフォルダー (2).csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"--project",
"${workspaceFolder}/新しいフォルダー (2).csproj"
],
"problemMatcher": "$msCompile"
},
{
"appId": "batch-http",
"appPort":7001,
"httpPort":3500,
"grpcPort":50001,
"label": "dapr-debug-clr",
"componentsPath": "C:\\Users\\tengyanbo\\Desktop\\UMFG\\新しいフォルダー (2)\\components",
"isBackground": true,
"type": "dapr",
"dependsOn": "build"
},
{
"label": "daprd-down-clr",
"appId": "batch-http",
"type": "daprd-down"
}
]
}
和解释性语言差不多,需要注意下这里的dependsOn即可。这样就能先build,再运行dapr,最后启动C#程序。
写在最后
dapr调试还是涉及挺多东西的,多多看看配置文件,能对dapr的运行有一个基本的了解。
后续会更新docker的调试,k8s,windbg调试等一系列的调试技巧。
公众号
更多内容,欢迎关注我的微信公众号: 半夏之夜的无情剑客。