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

launch.json cannot detect the project binary #1167

Closed
qiansen1386 opened this issue Feb 1, 2017 · 9 comments
Closed

launch.json cannot detect the project binary #1167

qiansen1386 opened this issue Feb 1, 2017 · 9 comments

Comments

@qiansen1386
Copy link

Environment data

Product Information:
Version: 1.0.0-preview2-1-003177
Commit SHA-1 hash: a2df9c2576
Runtime Environment:
OS Name: Windows
OS Version: 10.0.14393
OS Platform: Windows
RID: win10-x64
VS Code version: 1.8.1
C# Extension version:1.6.2

Steps to reproduce

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

IMO, the real issue here is the project kick-starting process is way too tedious for a console project.

Actual behavior

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

Expected behavior

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?

@qiansen1386
Copy link
Author

Originally reported @ microsoft/vscode#10040

@DustinCampbell
Copy link
Member

DustinCampbell commented Feb 1, 2017

When the C# extension loads, it will offer to generate a launch.json for you. However, it looks like that didn't happen and it's not clear to me where in your repro steps that you actually opened the project in VS Code. Try the following:

  1. dotnet new

  2. dotnet restore

  3. Open the project folder in VS Code.

  4. At this point, the C# extension should be loaded. If it isn't try opening a C# file, which will cause it to load.

  5. Once it's loaded, you'll see a message pop up like this:

    image

  6. Click 'Yes'

  7. F5 to start debugging

@qiansen1386
Copy link
Author

qiansen1386 commented Feb 1, 2017

Thanks a lot, sir.
I have tried your excellent solution, it work as you said, however, it maybe too much, but I still wondering if it is possible to embed multiple projects in one root folder. That means when we have to deal with more than one entry points, we will no longer have to either open multiple windows or jump back and forth to different folder via some commands. It could be very inconvenient when project grows bigger and bigger.
I heard that VS code team is adding support for managing multiple git projects at once. Is is possible one day we can manage multiple c# entry points in one root?
There are a few of thoughts:

  1. To put launch.json in each subfolder. Make sure VS Code can scan and get aware of their existences.
  2. To put multiple configuration blocks in root launch.json file. Then we have to specify the code scope for each entry point. For example, we trigger debugger of project2.dll when current editing file is under project2/ folder.
  3. To come up with some general placeholder which can generalize different folder name, assuming the project structure for each new dotnet Core project created by dotnet new are exactly the same and all entry-point projects must be under the same root folder. e.g.${workspaceRoot}/<Project-name>/bin/Debug/<target-framework>/<project-name.dll> That make sense because in Visual Studio IDE, we put all the projects horizontally under one root solution.

@DustinCampbell
Copy link
Member

You can achieve this today by manually adding configurations to the launch.json file. However, you're right that this can become inconvenient as the project grows larger. We've asked for a feature in VS Code that would allows us to dynamically add launch.json configurations from the underlying project structure that we detect, which could solve this. But it hasn't been accepted or implemented yet (microsoft/vscode#10861).

To put launch.json in each subfolder. Make sure VS Code can scan and get aware of their existences.

That would be a change to VS Code itself, which isn't something we can handle from the extension.

To put multiple configuration blocks in root launch.json file. Then we have to specify the code scope for each entry point. For example, we trigger debugger of project2.dll when current editing file is under project2/ folder.

We're thinking of doing something like that in the future (#310).

To come up with some general placeholder which can generalize different folder name, assuming the project structure for each new dotnet Core project created by dotnet new are exactly the same and all entry-point projects must be under the same root folder. e.g."${workspaceRoot}//bin/Debug//<project-name.dll>" That make sense because in Visual Studio IDE, we put all the projects horizontally under one root solution.

This is possible as well. I've noticed that the Bash Debug extension tries to do something like that.

@DustinCampbell
Copy link
Member

Thanks very much for your feedback @qiansen1386. I'm going to go ahead and close this, as we already have at least one issue tracking further work. Do let us know if you have further feedback. Thanks!

@bijayy33
Copy link

bijayy33 commented Oct 1, 2017

Thanks @DustinCampbell, it worked for me.

@santhakumar11
Copy link

Thanks DustinCampbell. i had same issues in my project

@Mona1988
Copy link

Mona1988 commented Jul 3, 2018

had the same problem and I had to download the version that specified in the console error. And then
follow the steps in this link.. make sure to open a new command prompt to execute the commands

https://www.microsoft.com/net/learn/get-started/windows

@TheIdanLapid
Copy link

TheIdanLapid commented Aug 28, 2018

dotnet new
Prints: "Usage: new [options]... (and then the rest of the help text)"

dotnet restore
Prints: "Nothing to do. None of the projects specified contain packages to restore."

But still I can't run the program.cs with F5 because of this line in launch.json:
"program": "${workspaceFolder}/bin/Debug//.dll"

I don't have a bin/Debug folder in my sln folder because I couldn't even debug it once. I'm stuck on this error before it even starts debugging/running.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants