Visual Studio Code Compilation Error - start.json must be configured

I am trying to compile C # code in Windows 7 using visual studio code. I have all the extensions loaded, but I get this error:

launch: program launch: launch.json must be configured. Change the β€œprogram” to the path to the executable you want to debug.

I can’t figure out how to fix this. This is the line which, in my opinion, should be changed in the launch.json file, this is what currently exists:

"program": "$ {workspaceRoot} /bin/Debug/netcoreapp1.0/exam 1.dll"

(exam 1 because this is the name of my .cs file containing my C # code)

When I go to the folder where my .cs file is located, this is the whole way:

  • "C: \ Users \ Kdrumz \ Desktop \ ObjectOriented \ exam 1.cs".

I am very confused. Also, will I always have to do this when using the visual studio code? Any help is much appreciated!

Using Visual Studio Code Version 1.7.1

+7
source share
3 answers

I fixed it by replacing all the values ​​"<>" in the style of launch.json as follows (the project in my case is called "sample01"):

 { "version": "0.2.0", "configurations": [ { "name": ".NET Core Launch (console)", "type": "coreclr", "request": "launch", "preLaunchTask": "build", "program": "${workspaceRoot}/bin/Debug/netcoreapp1.0/sample01.dll", "args": [], "cwd": "${workspaceRoot}", "stopAtEntry": false, "externalConsole": false } } } 

As you can see, I use only one configuration, which is called ".NET Core Launch (console)". This name can be changed, and you will see it when you click on the debug menu in the far left corner (that is, with an error symbol) and look at the very top.

Now I have entered the full path of my build-config (which is .NET Core 1.0 in my example) and it works.

So, yes, you will have to do this manually if it is preconfigured with "<>" elements. If you are using dotnet new , then code . to output new projects, new versions of Visual Studio code will now create launch.json ready for launch.

+11
source

For those who are still facing this problem:

  • Open the Program.cs file before starting to debug.
    • Opening any .cs file causes the C # extension.
  • The extension will then ask if it can load assembly assets. Hit Yes.
    • Omnisharp loading may take several seconds.
    • He requests this only if launch.json and tasks.json are not already added to the project.
  • Then the extension will configure your launch.json and tasks.json for you.

For those who want, there is an issue tracking this behavior.

+1
source

1) Open the project directory / folder in Explorer (Windows) or Finder (Mac).

2) Go to bin/Debug/netcoreapp{version}/{projectName}.dll and make sure that you copy the absolute and full path to the main project DLL and put it as the value for all program elements inside your launch.json .

Be sure to change all program elements in all sections in launch.json (console / web)

 { ... ... "program": "/Users/msoliman/Workspace/ProjectName/bin/Debug/netcoreapp1.0/MyProject.dll", ... ... } 
0
source

Source: https://habr.com/ru/post/1012640/


All Articles