Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VSCode Unable to Recognise default "program" in launch.json #10040

Closed
sebasijan opened this issue Aug 2, 2016 · 9 comments
Closed

VSCode Unable to Recognise default "program" in launch.json #10040

sebasijan opened this issue Aug 2, 2016 · 9 comments
Assignees
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues info-needed Issue requires more information from poster

Comments

@sebasijan
Copy link

  • VSCode Version: 1.3.1
  • OS Version: Windows 7 Professional

Steps to Reproduce:

  1. Create a new Console Application using the powershell script:

    function New-ConsoleApplication {
        param (
            [string]$Path,
            [string]$Name,
            [bool]$Open,
            [bool]$Run
        )
    
        New-Item -Name $Name -Type Directory -Path $Path
        cd "$Path\$Name"
        dotnet new
        dotnet restore 
        if ($Open){code .}
        if ($Run) {dotnet run}
    }
    
    New-ConsoleApplication -Name "ConsoleApplication" -Path "C:\Users\First.Surname\Source\" -Open $true -Run $true`
    
  2. The folder structure and code is created, and it is opened in VSCode. The application executes and prints "Hello World!" to the PowerShell terminal.

PowerShell Output:

    Directory: C:\Users\Seb.Kotze\Source


    Mode                LastWriteTime     Length Name                              
    ----                -------------     ------ ----                              
    d----        02/08/2016     16:06            ConsoleApplication                
    Created new C# project in C:\Users\Seb.Kotze\Source\ConsoleApplication.
    log  : Restoring packages for C:\Users\Seb.Kotze\Source\ConsoleApplication\proj
    ect.json...
    log  : Writing lock file to disk. Path: C:\Users\Seb.Kotze\Source\ConsoleApplic
    ation\project.lock.json
    log  : C:\Users\Seb.Kotze\Source\ConsoleApplication\project.json
    log  : Restore completed in 2514ms.
    Project ConsoleApplication (.NETCoreApp,Version=v1.0) will be compiled because 
    expected outputs are missing
    Compiling ConsoleApplication for .NETCoreApp,Version=v1.0

    Compilation succeeded.
        0 Warning(s)
        0 Error(s)

    Time elapsed 00:00:01.5621203


    Hello World!
  1. In VSCode, click Debug or Ctrl + Shift + D, then press F5
  2. Select .NET Core as the environment - launch.json is opened - then press F5 again
  3. No task runner configured

  4. Select Configure Task Runner - select .NET Core - tasks.json is opened
  5. Press F5 to launch
  6. launch: launch.json must be configured. Change 'program' to the path to the executable file that you would like to debug.

  7. open launch.json
  8. Program is given by : "${workspaceRoot}/bin/Debug/<target-framework>/<project-name.dll>"
  9. Changing this to the physical path of the .dll resolves the issue, but VSCode complains that :

Relative paths will no longer be automatically converted to absolute ones. Consider using ${workspaceRoot} as a prefix.
Path to the application dll or .NET Core host executable to launch. Example: '${workspaceRoot}/bin/Debug//<project-name.dll>' where:
: (example: 'netstandard1.5') This is the name of the framework that the app is being built for. It is set in the project.json file.
: (example: 'MyApp') The name of the project being debugged.

@aeschli aeschli assigned dbaeumer and isidorn and unassigned dbaeumer Aug 2, 2016
@isidorn
Copy link
Contributor

isidorn commented Aug 26, 2016

@sebasijan do you still see this issue with vscode 1.4? If you keep using the ${workspaceRoot} do you end in this situation every time you try to start debugging?

@isidorn isidorn added info-needed Issue requires more information from poster debug Debug viewlet, configurations, breakpoints, adapter issues labels Aug 26, 2016
@sebasijan
Copy link
Author

@isidorn After trying the above steps in 1.4.0 it seems to be working fine (I can see the program output in the console after pressing F5).

@DaveSlinn
Copy link

I'm getting this exact same error on v1.7.1 on macOS 10.11 (El Capitan). I'm extremely new to macOS so maybe I don't have something configured correctly. When I execute dotnet run from the terminal, it works fine. But after going through the VS Code automatic steps of adding a launch.json and tasks.json, I get this message when I try to debug through VS Code.

@isidorn
Copy link
Contributor

isidorn commented Nov 9, 2016

@gmsDave make sure your program attribute is launch.json is has a correct absolute paht - or is using ${workspaceRoot}. If the problem still occurs I recommend to file it to the C# extension since the launching of your program is done on the extension side
https://github.com/OmniSharp/omnisharp-vscode

@DaveSlinn
Copy link

DaveSlinn commented Nov 9, 2016

It was set to ${workspaceRoot}/bin/Debug/<target-framework>/<project-name.dll> but even setting program to the exact path, /Users/daveslinn/desktop/dotnet/bin/debug/netcoreapp1.0/dotnet.dll, was still giving the same error, "launch: launch.json must be configured. Change 'program' to the path to the executable file that you would like to debug.". I will head over to OmniSharp and re-post there.

Correction: setting the exact path does fix the issue. I originally changed it on the wrong configuration - the web one, not the console one.

D-oh! Such a rookie mistake. The correct value should be ${workspaceRoot}/bin/Debug/netcoreapp1.0/dotnet.dll. I didn't understand that the angle brackets were only placeholders that I needed to update. I thought they would be auto-filled at runtime based on my config. Guess I was wrong. Once I changed those to their actual values, running debug in vs code works, even using the ${workspaceRoot} variable.

@qiansen1386
Copy link

qiansen1386 commented Jan 31, 2017

"configurations": [
        {
            "name": ".NET Core Launch (console)",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build",
            "program": "${workspaceRoot}/bin/Debug/<target-framework>/<project-name.dll>",
            "args": [],
            "cwd": "${workspaceRoot}",
            "stopAtEntry": false,
            "externalConsole": false
        },
launch.json

For "program": "${workspaceRoot}/bin/Debug/<target-framework>/<project-name.dll>",, you must find and paste in the exact path of the dll file like ${workspaceRoot}/bin/Debug/netcoreapp1.1/project1.dll in order to hook the debuger up. In this case, what's the point of having the wildcard placeholder anyway?

Dear coordinator, the real issue here is the project kick-starting process is way too tedious for a console project.
You see, to start the project, we have to go through following steps:

  1. We can only put the bin folder under the root folder, otherwise the .vscode/ will not work. If we need more than one project -> Open more than one new windows, instead of creating multiple sub-folder in the same workspace.
  2. Run dotnet new
  3. Run dotnet restore
  4. Choose debug page on sidebar, click on run button, and select launch.json profile to ".net Core"
  5. Click on Set task runner, but it only generate a default file, apperently there is nothing to set.
  6. Paste the exact path of main dll to program attribute of configuration of launch.json, as being said, otherwise the debugger won't work.
  7. Start Debugging

What we really want:

  1. New folder
  2. Run dotnet new in it.
  3. Start Debugging

I wonder if it is possible. Is this the wrong place to report the issue?

@isidorn
Copy link
Contributor

isidorn commented Jan 31, 2017

@qiansen1386 please file this feedback against the c# extension as this can be improved on their side
https://github.com/OmniSharp/omnisharp-vscode

@qiansen1386
Copy link

@isidorn Thanks

@kendrahavens
Copy link

For anyone still hitting this issue.

  1. Open up your Program.cs file before starting to debug.
  2. Opening any .cs file fires the C# extension.
  3. The extension will then ask if it can load build assets . Hit Yes.
    • It may take a few seconds to load Omnisharp
    • It only asks this if the launch.json and tasks.json haven't already been added to the project.
  4. Then the extension will configure your launch.json and tasks.json for you.

For those interested there is an issue tracking this behavior.

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

6 participants