Steps to Reproduce:
```
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`
```
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!
Debug or Ctrl + Shift + D, then press F5.NET Core as the environment - launch.json is opened - then press F5 againConfigure Task Runner - select .NET Core - tasks.json is openedF5 to launchlaunch.json Program is given by : "${workspaceRoot}/bin/Debug/<target-framework>/<project-name.dll>".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// ' 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.
@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 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).
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.
@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
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.
"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
},
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:
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.dotnet newdotnet restorelaunch.json profile to ".net Core"What we really want:
dotnet new in it.I wonder if it is possible. Is this the wrong place to report the issue?
@qiansen1386 please file this feedback against the c# extension as this can be improved on their side
https://github.com/OmniSharp/omnisharp-vscode
@isidorn Thanks
For anyone still hitting this issue.
For those interested there is an issue tracking this behavior.
Most helpful comment
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.