I am trying to run the VS Code debugger for the first time for my .NET 9 web api. When I hit F5 it doesn’t start debugging and I get this message:
You don’t have an extension for debugging XML. Should we find a XML extension in the Marketplace?
So to fix this issue, I asked Github Copilot what to do to make it work. This was it’s response.
Step-by-step solution:
1. Install the official C# extension (if not already done).
2. Avoid focusing on your .csproj file when starting debugging—open one of your C# source files.
3. Create a launch configuration file to explicitly start debugging your web API.
And this was the launch.json file it created.
{
"version": "0.2.0",
"configurations": [
{
"name": ".NET Launch Web API",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/dotnetapivue3.Server/bin/Debug/net9.0/dotnetapivue3.Server.dll",
"args": [],
"cwd": "${workspaceFolder}/dotnetapivue3.Server",
"stopAtEntry": false,
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
]
}
I added the file to my project then, opened a controller file. Launched the debugger. After that, the project loaded as expected and I was able to set break points for debugging.