.netvisual-studio-codedebugging

VSCode doesn't find sln file when debugging


I am trying to run a console app in debug mode using VSCode.

My .sln file is in a "src" folder (see https://github.com/cosmo0/arcade-manager).

I have multiple projects in the solution: a web API, a class library, and a console exe. I want to launch the console in debug mode.

My launch.json file is as follows:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "ArcadeManager Console",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build",
            "program": "${workspaceFolder}/src/ArcadeManager.Console/bin/Debug/net8.0/ArcadeManager.Console.dll",
            "args": [],
            "cwd": "${workspaceFolder}/src/ArcadeManager.Console",
            "stopAtEntry": false,
            "console": "internalConsole"
        }
    ]
}

When I try to run the configuration, I get the following:

Executing task: C:\Program Files\dotnet\dotnet.exe build C:\Dev\arcademanager/ArcadeManager.sln /property:GenerateFullPaths=true /consoleloggerparameters:NoSummary;ForceNoAlign

MSBUILD : error MSB1009: Le fichier projet n'existe pas. Commutateur : C:\Dev\arcade-manager/ArcadeManager.sln

As you can see it searches for the proper file, but not in the proper folder?

How do I specify it the proper path to the sln file?

Thanks!


Solution

  • Ok so I found the culprit.

    In the files explorer (not the .Net solution explorer, not the debug panel) there is a file .vscode\tasks.json which is documented here: https://code.visualstudio.com/docs/editor/tasks

    It turns out this is what launch.json is referring to in the preLaunchTask property: the name of an entry in the tasks list.

    Here the build task was in fact defined with the wrong path to the sln file.