debug a project.json command in visual studio - visual-studio

I have the following entry in project.json:
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel"
}
I have until now been running 'dnx web' on the command line to start up my server. However, I would like to start it in such a way that I can debug (i.e. execution will hit the breakpoints that I set). How can I do this?
Thanks in advance.

Make sure your startup project of your solution is pointing at a project that can be started by one of the commands you have in project.json. If it is, then the command will appear in the start menu at the top of visual studio so that you can start it in debug mode.

Related

How to properly stop running dotnet core web application?

In Visual Studio 2017 and 2019 on Windows, I run dotnet watch run in the Package Manager Console. It launched kestrel for a dotnet core app, automatically disabled text edit in the console, and displayed a red button to stop command execution, but the button doesn't do anything. Also, the message is being displayed to use Ctrl+C but it doesn't work either.
Now listening on: http://localhost:20436 Application started. Press Ctrl+C to shut down.
Now there is an error when I try to launch the web app in Visual Studio because it is already running.
I couldn't find a command like dotnet stop only Ctrl+C which doesn't work in this case. I used Process Hacker to kill the dotnet.exe process but that doesn't seem right. What would be the best way to kill the running process?
Since this stop option doesn't work it is clearly a bug. If I need to run dotnet watch run I generally just open command line on my current folder outside VS and run it from there. Since dotnet watch run has nothing to do with visual studio (no debugging) it makes sense. Alternatively, you can use the green button to run within visual studio with debugger. However, this would mean you can't edit the code while testing.
run your project:
dotnet run > Examplelog.log &
$ dotnet run > Examplelog.log &
[1] 162
end your project:
kill 162
$ kill 162
[1]+ Exit 127 dotnet run > Examplelog.log
So with kill[id] you can end your process.
you not need a second console and can use your console for other inputs (take note that all outputs will be stored inside the Examplelog.log-File you have to check)^^lg
when the service is already running just again apply build command "dotnet build" and then again run command apply like "dotnet run"
services will be up again then you just have to press Ctrl+c in the terminal to shutdown running services.
There is a red button next to the clear button in that section next to the project name. I just found it LOL I will show you a picture follow the yellow circle. I was trying ctrl+c too LOL

Debug jHipster application

I'm new to jHipster, I've created APIs which are consumed by my application's front end. I want to debug my services but unable to attach debugger with IntelliJ.
My application starts by running command "mvnw" which is jHispter standard command when I opened this bat file in editor i found this :
#REM e.g. to debug Maven itself, use
#REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
I setup MAVEN_OPTS environment variable but still it was of no use. I also tried to make a remote connection from IDE on port 8000 but still, it didn't serve a purpose.
Any help will be appreciated, thanks.
you can just run (in debug mode) the main method in the JhipApp Class (the SpringBootApplication Class). It worked for me
My tested and proven solution for debugging and then dividing the front end with the back ends, works for OS Windows and Ubuntu with the use of the latest version of the Ide Intellij Community (2020.1.1 used in both OS), provides that after creating a jhipster app (created with Ubuntu), from the command promp or from the Ubuntu shell launch the command: mvn -DskipTests = true clean install to compile the back end first and then the front end (in Angular 8 in my case), at the end of this compilation run the following command: mvn spring-boot: run.
After launching the application, click Ctrl + C and stop the run. Now you can launch the npm commands and then the command: npm start from the same command prompt or from the shell, since your project has been built and already launched it will be restarted and now from the Ide you can launch your class configuration annotated with #SpringBootApplication from the debug icon, at the end of the compilation you will have front ends and back ends divided and debuggable easily as well as hot changes for the front end take place quickly, while for the back end you will always have to save recompile and restart in debug.
You can do it, if you connect remotely, as you suggested in your question
Start jhipster in the terminal, but pass in some debug params
$ ./mvnw -Dspring-boot.run.jvmArguments="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"
Then you just connect to it using your IDE at port 5005.
For example, in Visual Studio Code
add a "launch.json" file
A "Add Configuration" button will be displayed when you have the launch.json as the active file in the editor. Click it.
Choose "Java: Attach by Process Id"
That will add a new configuration to the "Run and Debug" tab.
Click the "Attach by Process ID", button, and choose your process (port 5005 in this example)
Debugging will begin!

How to debug revel app in goland?

I would like to debug my revel application with Jetbrain's gogland built in debugger but gogland run configuration allowing to setup either package or file run scenario not debug process started by revel run myapp.
Now Gogland is Goland
I find official manual for create debug-config. I'll post here if you do not mind...
INTELLIJ DEBUGGING (GOLAND)
Create your project, for this example i will be using canonical “revel new github.com/myaccount/my-app”
“revel run github.com/myaccount/my-app” to generate tmp/main.go - this file is needed by intellij
Shutdown the running server
Create run configuration and in “Program arguments” add “-importPath github.com\myaccount\my-app -srcPath \src -runMode dev"
Point “File” to \src\github.com\myaccount\my-app\app\tmp\main.go
In “before launch” add “Run external tool”. There: Program: \bin\revel(.exe) Paramerets: build github.com/myaccount/my-app
It works for Linux&Windows
AFAIK, Gogland built-in debugger is delve.
I think you must try run debug with option attach:
Attach to an already running process and begin debugging it.
This command will cause Delve to take control of an already running process, and
begin a new debug session. When exiting the debug session you will have the
option to let the process continue or kill it.
Usage:
dlv attach pid [flags]
I don't have installed gogland now, but I had similar problem in past.

Visual Studio Code Debugging with dotnet cli watch option

I am able to debug aspnet.core webapi with { request: launch, type: coreclr, program: **.dll } or to update webapi code without restarting server with npm task { start: "dotnet watch run" }.
But I am not able to use both features in the same session. I tried to attach to both browser or server with no luck.
I'd also like to know if this is possible with current version of vscode.
According to this GitHub issue, is is not possible to use VS Code with the the dotnet watch option.
Q: How to configure vs code debugger to use dotnet watch?
A: I don't think this is feasible...

Run a solution in debug mode if MSBuild compilation is successful from the command line

I am looking to improve my personal development process. I would like to create a batch file or similar that I can run from Windows PowerShell or the plain-old command line that does the following:
Compiles my solution (e.g. C:\Windows\Microsoft.NET\Framework\v3.5\MSBuild.exe /m:8 "%CD%\MySolution.sln")
If the compilation was successful, run it in debug mode, attaching the visual studio debugger, otherwise stop.
In essence, I am trying to replicate the behavior of pressing F5 in Visual Studio, but invoked from the command line. Is this possible? The reason for all this, is that I find the VS UI responsiveness degrades significantly when invoking MSBuild commands from within the IDE.
msbuild
if($?) {
# launch your process
Debug-Process -name "<Your Process Name>"
}

Resources