基于VS Code的AI编辑器Debug ASP.NET Core 程序

问题

image

https://github.com/dotnet/vscode-csharp/blob/main/docs/debugger/Microsoft-.NET-Core-Debugger-licensing-and-Microsoft-Visual-Studio-Code.md

下载netcoredbg

地址:https://github.com/Samsung/netcoredbg

tasks.json

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build",
            "command": "dotnet",
            "type": "process",
            "args": [
                "build",
                "${workspaceFolder}/YOURAPP.csproj",
                "/property:GenerateFullPaths=true",
                "/consoleloggerparameters:NoSummary"
            ],
            "problemMatcher": "$msCompile"
        },
        {
            "label": "publish",
            "command": "dotnet",
            "type": "process",
            "args": [
                "publish",
                "${workspaceFolder}/YOURAPP.csproj",
                "/property:GenerateFullPaths=true",
                "/consoleloggerparameters:NoSummary"
            ],
            "problemMatcher": "$msCompile"
        }
    ]
}

launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": ".NET Core Launch (netcoredbg)",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build",
            "program": "${workspaceFolder}\\YOURAPP\\bin\\Debug\\net9.0\\YOURAPP.dll",
            "args": [],
            "cwd": "${workspaceFolder}\\YOURAPP",
            "stopAtEntry": false,
            "console": "internalConsole",
            "env": {
                "ASPNETCORE_ENVIRONMENT": "Development",
                "ASPNETCORE_URLS": "http://localhost:9004"
            },
            "pipeTransport": {
                "pipeCwd": "${workspaceFolder}\\YOURAPP",
                "pipeProgram": "powershell", 
                "pipeArgs": [
                    "-c"
                ],
                "debuggerPath": "${workspaceFolder}\\.vscode\\netcoredbg\\netcoredbg.exe",
                "quoteArgs": true
            },
            "serverReadyAction": {
                "action": "openExternally",
                "pattern": "\\bNow listening on:\\s+(https?://\\S+)",
                "uriFormat": "%s/swagger/index.html"
            }
        }
    ]
}
posted @ 2026-01-26 19:51  talentzemin  阅读(0)  评论(0)    收藏  举报