安装插件C# Dev Kit,使用的版本是1.41.11
.NET Install Tool一般会自动安装,安装C# dev kit的时候,版本2.3.7
C# 插件,版本2.87.31
https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.vscode-dotnet-runtime
https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp
https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csdevkit
下载vsix然后拖拽到侧边栏即可自动安装
与操作系统平台相关,可在下载链接后增加:“?targetPlatform={platform}”,如:
https://marketplace.visualstudio.com/_apis/public/gallery/publishers/ms-dotnettools/vsextensions/csharp/2.63.32/vspackage?targetPlatform=win32-x64
platform选项:
win32-x64: Windows 64-bit
win32-ia32: Windows 32-bit
win32-arm64: Windows ARM64
darwin-x64: macOS Intel
darwin-arm64: macOS Apple Silicon
linux-x64: Linux 64-bit
linux-arm64: Linux ARM64
alpine-x64: Alpine Linux
下载地址如下
https://marketplace.visualstudio.com/_apis/public/gallery/publishers/ms-dotnettools/vsextensions/vscode-dotnet-runtime/2.3.7/vspackage
https://marketplace.visualstudio.com/_apis/public/gallery/publishers/ms-dotnettools/vsextensions/csharp/2.87.31/vspackage?targetPlatform=win32-x64
https://marketplace.visualstudio.com/_apis/public/gallery/publishers/ms-dotnettools/vsextensions/csdevkit/1.41.11/vspackage?targetPlatform=win32-x64
安装顺序安装即可,如果版本不支持就降低一个版本
ctrl+shift+p
选择保存的文件夹,然后输入项目名称即可
选择解决方案格式
确认路径之后创建成功
配置如下
{// 使用 IntelliSense 了解相关属性。 // 悬停以查看现有属性的描述。// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387"version": "0.2.0","configurations": [{"name": "WebApplication1","type": "dotnet","request": "launch","projectPath": "${workspaceFolder}/WebApplication1/WebApplication1.csproj"},]
}
微软做了限制,可以愉快写代码,如果可以接受两个编辑器调试建议vs或者vs code,不接受的话可以接入三星的netcoredbg
https://github.com/Samsung/netcoredbg
解压到E:\Software\netcoredbg
新建tasks.json
{"version": "2.0.0","tasks": [{"label": "build","command": "dotnet","type": "process","args": ["build","${workspaceFolder}/WebApplication1"],"problemMatcher": "$msCompile"}]
}
修改launch.json
{"version": "0.2.0","configurations": [{"type": "coreclr","request": "launch","preLaunchTask": "build","name": ".NET Core Launch (console)","program": "${workspaceFolder}/WebApplication1/bin/Debug/net9.0/WebApplication1.dll","args": [],"cwd": "${workspaceFolder}","stopAtEntry": false,"internalConsoleOptions": "openOnSessionStart","pipeTransport": {"pipeCwd": "${workspaceFolder}","pipeProgram": "cmd","pipeArgs": ["/c"],"debuggerPath": "E:\\Software\\netcoredbg\\netcoredbg.exe","debuggerArgs": ["--interpreter=vscode"],"quoteArgs": true},}]
}
开始调试
代码
链接:https://pan.quark.cn/s/45dedc25c5b4
提取码:7H7s
参考
https://github.com/Trae-AI/Trae/issues/311
https://blog.csdn.net/wzl644/article/details/146067628
https://engincanveske.substack.com/p/debug-your-net-apps-in-cursor-code