'Remote debugging with VS Code on Windows to a Raspberry Pi
I need help to setup my vscode in order to deploy and debug a dotnet application on my RPi 4 (Raspberry Pi OS x64), because I'm not able to attach the vscode debugger.
The application is correctly built and deployed on my RPi, and I can run it via ssh using the command dotnet ~/MyFirstApp/MyFirstApp.dll, but when I try to run it using the debugging function of vscode it returns the following error:
Could not execute because the specified command or file was not found.
Possible reasons for this include:
* You misspelled a built-in dotnet command.
* You intended to execute a .NET program, but dotnet-~/MyFirstApp/MyFirstApp.dll does not exist.
* You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
Here all the files:
MyFirstApp.cs
Console.WriteLine("Hello, World!");MyFirstApp.csproj
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework>net6.0</TargetFramework> <ImplicitUsings>enable</ImplicitUsings> <Nullable>enable</Nullable> </PropertyGroup> </Project>.vscode/launch.json
{ "version": "0.2.0", "configurations": [ { "name": ".NET Core Launch (remote)", "type": "coreclr", "request": "launch", "preLaunchTask": "RaspberryPiDeploy", "program": "~/.dotnet/dotnet", "args": ["~/${workspaceFolderBasename}/${workspaceFolderBasename}.dll"], "cwd": "~/${workspaceFolderBasename}", "stopAtEntry": false, "console": "internalConsole", "pipeTransport": { "pipeCwd": "${workspaceFolder}", "pipeProgram": "ssh", "pipeArgs": [ "[email protected]" ], "debuggerPath": "~/vsdbg/vsdbg" } } ] }.vscode/tasks.json
{ "version": "2.0.0", "tasks": [ { "label": "build", "command": "dotnet", "type": "process", "args": [ "build", "${workspaceFolder}/MyFirstApp.csproj", "/property:GenerateFullPaths=true", "/consoleloggerparameters:NoSummary" ], "problemMatcher": "$msCompile" }, { "label": "RaspberryPiPublish", "command": "sh", "type": "shell", "dependsOn": "build", "windows": { "command": "cmd", "args": [ "/c", "\"dotnet publish -r linux-arm64 -o bin\\linux-arm64\\publish --no-self-contained\"" ], "problemMatcher": [] } }, { "label": "RaspberryPiDeploy", "type": "shell", "dependsOn": "RaspberryPiPublish", "presentation": { "reveal": "always", "panel": "new", "close": true }, "windows": { "command": "scp -r bin\\linux-arm64\\publish\\* [email protected]:${workspaceFolderBasename}" }, "problemMatcher": [] } ] }
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
