安裝插件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