C#-VS代码-launch:program ...不存在 [英] C# - VS Code - launch:program ... does not exist
问题描述
我正在尝试在VS Code中调试一个简单的"Hello world"应用程序,但是,当我按Ctrl + F5时,它给了我以下错误:
I am trying to debug a simple "Hello world" application in VS Code, however, when I press Ctrl + F5, it gives me the following error:
如果我从以下位置手动更改launch.json中的路径:
If I manually change the path in launch.json from:
${workspaceFolder}/bin/Debug/insert-target-framework-here/insert-project-name-here.dll
收件人:
"${workspaceFolder}/bin/Debug/netcoreapp2.1/test.dll"
它确实可以工作,但是在没有我手动输入路径的情况下它还可以正常工作.另外,我注意到VS Code不再像以前那样要求重建资产:
It does work, however before it was working fine without me manually typing the path. Also, I have noticed that VS Code no longer asks to rebuild assets like it did before:
到目前为止,我已经尝试了以下方法:
So far I have tried the following:
先卸载VS Code,然后再安装.NET Core 2.1,然后从%USER%\.vscode \中删除VS Code扩展文件夹,重新安装VS Code,然后再安装.NET Core 2.1,然后再安装C#扩展名(对于Visual Studio为C#代码(由OmniSharp提供).
Uninstalled VS Code, then .NET Core 2.1, deleted the VS Code extension folder from %USER%\.vscode\ , re-installed VS Code, then .NET Core 2.1, and then the C# extension (C# for Visual Studio Code (powered by OmniSharp)).
当VS Code启动时,它确实会成功下载"OmniSharp"软件包,但是,当我打开C#文件时,仍然没有提示重建资产.调试产生了与以前相同的问题.
When the VS Code starts, it does download the "OmniSharp" package successfully, but still, no prompt to rebuild assets when I open a C# file. Debugging gives the same issue as before.
这是launch.json:
Here is the 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:
And the tasks.json:
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet build",
"type": "shell",
"group": "build",
"presentation": {
"reveal": "silent"
},
"problemMatcher": "$msCompile"
}
]
}
推荐答案
我找到了适合我的解决方案.我的VS代码给了我相同的错误消息,而我所做的修复是:
I found a solution that worked for me. My VS Code was giving me the same error message, and what I did to fix it was:
- Press the combination Ctrl + Shift + P
- Restart Omnisharp
- Then it asks if you want to add missing files for build.
- Click Yes.
此后,我便可以调试我的应用了.
After this I was able to debug my app.
希望它对您有用!
这篇关于C#-VS代码-launch:program ...不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!