Trigger Visual Studio Code Launch Program "Start Debugging" through terminal command - unix

I have a node.js application and I am trying to create a unix way to trigger Visual Studio Code Launch Program through terminal.
launch.json
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}/dist/server.js",
"outFiles": [
"${workspaceFolder}/dist/**/*.js"
]
}
]
}
I wanted to chain the terminal command to this;
npm run build && ?

Related

How does TeamsFx Hello World Tab sample app invoke local development?

I created the hello world tab example using TeamsFx toolkits VS Code extension. The part that I don't understand is how does the debug mode invoking the tab react app start script?
In the tasks.json file, there is a dependsOn teamsFx: frontend start setting. I couldn't figure out where frontend start script or frontend being declared.
Here is the task.json file
{
"version": "2.0.0",
"tasks": [
{
"label": "Pre Debug Check",
"dependsOn": ["dependency check", "prepare dev env"],
"dependsOrder": "sequence"
},
{
"label": "dependency check",
"type": "shell",
"command": "exit ${command:fx-extension.validate-dependencies}"
},
{
"label": "prepare dev env",
"dependsOn": ["prepare local environment", "frontend npm install"],
"dependsOrder": "parallel"
},
{
"label": "prepare local environment",
"type": "shell",
"command": "exit ${command:fx-extension.pre-debug-check}"
},
{
"label": "Start Frontend",
"dependsOn": ["teamsfx: frontend start"],
"dependsOrder": "parallel"
},
{
"label": "frontend npm install",
"type": "shell",
"command": "npm install --no-audit",
"options": {
"cwd": "${workspaceFolder}/tabs"
}
}
]
}
teamsfx: frontend start is a task contributed by Teams Toolkit extension using Visual Studio Code Extension API: Task Provider. Specifically, from TeamsFx GitHub repo:
the definition of this task is in https://github.com/OfficeDev/TeamsFx/blob/ms-teams-vscode-extension%403.8.0/packages/vscode-extension/package.json#L717-L729.
the implementation of this task is in https://github.com/OfficeDev/TeamsFx/blob/ms-teams-vscode-extension%403.8.0/packages/vscode-extension/src/debug/teamsfxTaskProvider.ts#L116-L129.

Unable to debbug R code on VSC running on Windows

I have installed the following extensions to VSC running on Windows: R, R Debugger, and R Tools, nevertheless, when I try to debug some R code, I get this message: Please install the R package: "vscDebugger".
I have tried to install it using install.packages("vscDebugger", repos="http://cran.us.r-project.org"), but it failed.
This is my launch.json:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "R-Debugger",
"name": "Launch R-Workspace",
"request": "launch",
"debugMode": "workspace",
"workingDirectory": "${workspaceFolder}"
},
{
"type": "R-Debugger",
"name": "Debug R-File",
"request": "launch",
"debugMode": "file",
"workingDirectory": "${workspaceFolder}",
"file": "${file}"
},
{
"type": "R-Debugger",
"name": "Debug R-Function",
"request": "launch",
"debugMode": "function",
"workingDirectory": "${workspaceFolder}",
"file": "${file}",
"mainFunction": "main",
"allowGlobalDebugging": false
},
{
"type": "R-Debugger",
"name": "Debug R-Package",
"request": "launch",
"debugMode": "workspace",
"workingDirectory": "${workspaceFolder}",
"includePackageScopes": true,
"loadPackages": [
"."
]
},
{
"type": "R-Debugger",
"request": "attach",
"name": "Attach to R process",
"splitOverwrittenOutput": true
}
]
}
I get the error with all options.
I found that the solution was to execute this command: "\Program Files\R\R-4.1.2\bin\R.exe" --no-restore --quiet -f "c:\Users\hugo.villalobos\.vscode\extensions\rdebugger.r-debugger-0.4.7\R\install.R" --args "https://github.com/ManuelHentschel/VSCode-R-Debugger/releases/download/v0.4.7/vscDebugger_0.4.7.zip"
The answer posted by #HuLu is not a correct answer as it uses his own R and vscode locations, the real solution to this problem comes from the R Debugger extension itself.
In the error description it states:
This extension is under development, you should try the command r.debugger.updateRPackage
So, now if the vscDebugger does not show up and you get an error when installing manually, try:
#command:
r.debugger.updateRPackage
Or the command:
Ctrl + Shift + P
R Debugger: Update or install the required R Package
When selecting this option, a very similar command to the mentioned by #HuLu gets executed.

How to change the browser of launching asp.net web api in visual studio code?

When I am trying to run asp.net web api project using visual studio code it lunches on Internet Explorer and I want to lunch it on Chrome .
That is the launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/bin/Debug/net5.0/Catalog.dll",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
// Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/Views"
}
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach"
}
]
}

Debugging ASP.NET Web App on VS Code Linux doesnt work

I'm testing out ASP.NET Core using this tutorial: https://www.blinkingcaret.com/2018/03/20/net-core-linux/
When building and running from the terminal, both the CLI and Web app works fine:
Web app:
dotnet run
Using launch settings from /home/peter/Documents/dotnet_linux/Reminders.Web/Properties/launchSettings.json...
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
User profile is available. Using '/home/peter/.aspnet/DataProtection-Keys' as key repository; keys will not be encrypted at rest.
Hosting environment: Development
Content root path: /home/peter/Documents/dotnet_linux/Reminders.Web
Now listening on: https://localhost:5001
Now listening on: http://localhost:5000
Application started. Press Ctrl+C to shut down.
However from VS Code 1.28.1 I can only run the CLI app. When I add a configuration for the web app:
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/Reminders.Web/bin/Debug/netcoreapp2.1/Reminders.Web.dll>",
"args": [],
"cwd": "${workspaceFolder}/Reminders.Web/bin/Debug",
"stopAtEntry": false,
"launchBrowser": {
"enabled": true,
"args": "${auto-detect-url}",
"windows": {
"command": "cmd.exe",
"args": "/C start ${auto-detect-url}"
},
"osx": {
"command": "open"
},
"linux": {
"command": "xdg-open"
}
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/Views"
}
},
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/Reminders.Cli/bin/Debug/netcoreapp2.1/Reminders.Cli.dll",
"args": [],
"cwd": "${workspaceFolder}/Reminders.Cli",
// For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window
"console": "internalConsole",
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
},
]
}
I get the error
This DLL does indeed exist.
I have looked through all config options for launch.json here: https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md but not found anything
You have an extra angle bracket.
Change
"program": "${workspaceFolder}/Reminders.Web/bin/Debug/netcoreapp2.1/Reminders.Web.dll>",
to
"program": "${workspaceFolder}/Reminders.Web/bin/Debug/netcoreapp2.1/Reminders.Web.dll",

Run grunt task with target/argument in VSCode

I have VSCode version 1.18.1, and this in my Gruntfile.js
grunt.registerTask('release', 'Release process', function(target) {
...
}
The target is there so that I can run grunt release:one or grunt release:two. However, I can't figure out how to make VSCode run the task with the one|two target.
This is tasks.json file VSCode created with Grunt task auto detected.
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"type": "grunt",
"task": "release",
"problemMatcher": [],
"label": "Release Process",
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
If I put release:one to the task attribute of the tasks.json file, VSCode will complain with something like
Error: The grunt task detection didn't contribute a task for the following configuration:
Anyone has done something similar to this? Can you please guide me on how to do it?
Thank you!
The way I solved this issue myself was by creating a Task of type shell instead, and putting in the full command. For example, you can do following:
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "Release one",
"command": "grunt release:one",
"problemMatcher": [],
}, {
"type": "shell",
"label": "Release two",
"command": "grunt release:two",
"problemMatcher": [],
}
]
}

Resources