佛山网站开发公司手机端关键词排名优化软件
1.背景
在Cursor下调试.Net Core控制台程序会出现下面的问题:
因为Cursor是VS Code的变种版本,并不被官方的调试机制支持去使用。基于这种情况,就产生了本文。
2.解决方法
使用三星电子的开源调试工具netcoredbg,就能解决这个问题
2.1 下载NetCoreDbg debugger
下载地址:https://github.com/Samsung/netcoredbg/releases
一般选择最新版本就行。我这里选的是 “netcoredbg-win64.zip”
2.2 解压netcoredbg
将步骤2.1下载的压缩包netcoredbg-win64.zip解压到C:\netcoredbg
完整地址是C:\netcoredbg\netcoredbg.exe
2.3.打开Cursor
然后在项目根目录下创建.vscode
文件夹,在文件夹下创建俩个文件launch.json、tasks.json
launch.json:
{"version": "0.2.0","configurations": [{"type": "coreclr","request": "launch","preLaunchTask": "build","name": ".NET Core Launch (console)","program": "${workspaceFolder}/ConsleVSCode/bin/Debug/net8.0/ConsleVSCode.dll","args": [],"cwd": "${workspaceFolder}","stopAtEntry": false,"internalConsoleOptions": "openOnSessionStart","pipeTransport": {"pipeCwd": "${workspaceFolder}","pipeProgram": "cmd","pipeArgs": ["/c"],"debuggerPath": "C:\\netcoredbg\\netcoredbg.exe","debuggerArgs": ["--interpreter=vscode"],"quoteArgs": true},}]
}
tasks.json:
{"version": "2.0.0","tasks": [{"label": "build","command": "dotnet","type": "process","args": ["build","${workspaceFolder}"],"problemMatcher": "$msCompile"}]
}
2.4 调试运行
在代码设置断点。按F5启动
从上图可以。我们成功运行,调试。
3.结论
本文是一个记录过程,帮助大家如何更好用好Cursor去开发C# .Netcore控制台项目。为了方便大家参考,我将相关资料和程序打包,有需要可以自取。
链接: https://pan.baidu.com/s/14qclktzijfDgnwqi7r1xhA?pwd=nx8h
提取码: nx8h