我试图在VS Code中调试一个简单的“Hello world”应用程序,但是当我按下Ctrl + F5时,它会给我以下错误:
如果我手动更改launch.json中的路径:
${workspaceFolder}/bin/Debug/insert-target-framework-here/insert-project-name-here.dll
收件人:
"${workspaceFolder}/bin/Debug/netcoreapp2.1/test.dll"
然而,它确实可以工作,但是之前在我手动输入路径之前它也能正常工作。另外,我注意到VS Code不再像以前那样询问重新构建资产:
我已尝试了以下方法:
卸载了VS Code、 .NET Core 2.1,从 %USER%\.vscode\ 中删除了VS Code扩展文件夹,重新安装了VS Code,然后再安装.NET Core 2.1和C#扩展(C# for Visual Studio Code (powered by OmniSharp))。
当VS Code启动时,它会成功下载“OmniSharp”包,但仍然没有提示在打开C#文件时重新构建资产。调试给出与之前相同的问题。
这是launch.json:
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/bin/Debug/<insert-target-framework-here>/<insert-project-name-here>.dll",
"args": [],
"cwd": "${workspaceFolder}",
"console": "internalConsole",
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart"
}
还有 tasks.json 文件:
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet build",
"type": "shell",
"group": "build",
"presentation": {
"reveal": "silent"
},
"problemMatcher": "$msCompile"
}
]
}