Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# - VS Code - launch:program ... does not exist

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:

enter image description here

If I manually change the path in launch.json from:

${workspaceFolder}/bin/Debug/insert-target-framework-here/insert-project-name-here.dll

To:

"${workspaceFolder}/bin/Debug/netcoreapp2.1/test.dll"

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:

enter image description here

So far I have tried the following:

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)).

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.

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"
    }

And the tasks.json:

    "version": "2.0.0",
"tasks": [
    {
        "label": "build",
        "command": "dotnet build",
        "type": "shell",
        "group": "build",
        "presentation": {
            "reveal": "silent"
        },
        "problemMatcher": "$msCompile"
    }
]
}
like image 499
RollerMobster Avatar asked Sep 18 '18 17:09

RollerMobster


2 Answers

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.

Hope it works for you!

like image 73
Robson William Avatar answered Oct 24 '22 09:10

Robson William


Visit your \bin\Debug\netcoreapp3.1 in your project folder (That you open in VS)

Go to launch.json file in VS:

Replace: "program": "${workspaceFolder}/bin/Debug//.dll",

With: "program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/CSharp.dll",

In may case, the project is called CSharp. Watch out.

like image 22
Ahmad hassan Avatar answered Oct 24 '22 11:10

Ahmad hassan