VSCode couldn't stop debug by debugger tab C# - c#

This project is Blazorwasm -- hosted.
I cannot click stop or restart debugger tab. I have to reopen VS Code for work again and I cannot debug code in VS Code. I cannot set breakpoint for check. I just can run from dotnet run or dotnet watch run How to resolve this problem.
This is my launch.json. Is this correct?
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch and Debug Standalone Blazor WebAssembly App",
"type": "blazorwasm",
"request": "launch",
"cwd": "${workspaceFolder}/Server"
}
]
}

Related

How can I use Godot 4.0 C# with dotnet run watch?

Godot 4.0 beta has shipped with C# support, and it reportedly works out of the box with hot-reload support in Visual Studio.
I would like to get this working on my Mac, which doesn't have Visual Studio. I took the launchSettings.json and put it in my Godot project in "Properties/launchSettings.json" with this content (taken from what Visual Studio autogenerated):
{
"profiles": {
"Development": {
"commandName": "Executable",
"executablePath": "/path/to/Godot_csharp_b1.app/Contents/MacOS/Godot",
"commandLineArgs": "--debug-server tcp://127.0.0.1:6666",
"workingDirectory": "/path/to/my/project",
"authenticationMode": "None",
"remoteDebugEnabled": false,
"remoteDebugMachine": ""
}
}
}
Now I try to do this:
dotnet watch run --launch-profile Development
However, it doesn't work. It gives this error:
The launch profile "Development" could not be applied.
The launch profile type 'Executable' is not supported.
Unable to run your project.
Ensure you have a runnable project type and ensure 'dotnet run' supports this project.
A runnable project should target a runnable TFM (for instance, net5.0) and have OutputType 'Exe'.
The current OutputType is 'Library'.
Is it possible to work around this? Any way to run Godot on MacOS with hot reloading would be acceptable for me - command line or anything else.
I'm on MacOS + M1 if that is important.
Edit: My original answer misunderstood the question, but I will leave it below as it may be helpful.
Regarding hot reloading, I am not sure Godot 4 is capable of playing nicely with dotnet watch as I haven't been able to find much on it. However, I was able to find this outstanding issue regarding hot reload in Godot 4 beta 3, but that's about it. It will likely be some time before Godot 4 reaches stable, so this may change rapidly over the coming weeks.
If you are trying to debug a Godot 4 C# project with Visual Studio Code, you can do so with the following launch.json configuration. Note that Visual Studio and Visual Studio Code are two entirely different IDE's. Just place the snippet below in a file at .vscode/launch.json in your Godot project:
{
"version": "0.2.0",
"configurations": [
// For these launch configurations to work, you need to setup a GODOT4
// environment variable. On mac or linux, this can be done by adding
// the following to your .zshrc, .bashrc, or .bash_profile file:
// export GODOT4="/Applications/Godot.app/Contents/MacOS/Godot"
{
"name": "Play",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${env:GODOT4}",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
},
}
}
Make sure you have a GODOT4 environment variable that points to your Godot4 executable.
You will also need to place the snippet below in your .vscode/tasks.json file, since the launch configuration above depends on it to make sure that dotnet build is run before debugging.
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build"
],
"problemMatcher": "$msCompile",
"presentation": {
"echo": true,
"reveal": "silent",
"focus": false,
"panel": "shared",
"showReuseMessage": true,
"clear": false
}
}
]
}
If you are looking for Godot 3 launch.json configurations, you can find those here.

Visual Studio Core not opening webapi in debug mode or `dotnet run`

We use Visual Studio Code to develop dotnet core webapis. Visual Studio Code has all of a sudden stopped opening the web apis in the browser when we use the Debug mode. Or, when using dotnet run. As a result, I don't know what URL and port has been assigned to the web application.
What's strange is that there are no errors during the build. And, the web application is written to NLog, so it is obviously running. It's just that it is not automatically opening in the browser, and the VSCode terminal is not returning the URL in the stdout.
Below is the launch.json file from the .vscode folder:
{
"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}/api-timesheets/bin/Debug/net6.0/api-timesheets.dll",
"args": [],
"cwd": "${workspaceFolder}/api-timesheets",
"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"
}
]
}

How to set a .NET project as StartUp in VS Code?

I'm using VS Code with the vscode-solution-explorer to develop a .NET solution.
For debugging, I've configured my .vscode/launch.json file to run a build solution task and to execute a specific C# project (.csproj file).
My problem is: this .NET solution uses the Microservices approach, so I have ~50 Web API projects and each time I need to debug a specific API, I need to open the .vscode/launch.json file and replace the project name in 4 different places.
What I would like to do is the same that I do in Visual Studio: I right-click in the project and select "Set as StartUp project", so every time I press F5 it will run this selected project.
My launch.json looks likes this:
{
"version": "0.2.0",
"configurations": [
{
"name": "MyProject",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/MyProject/bin/Debug/netcoreapp3.0/MyProject.dll",
"args": [],
"cwd": "${workspaceFolder}/MyProject.csproj",
}
]
}
You can create multiple configurations in launch.json file.
Check this post: How do I designate a startup project in VS Code?
Hope this helps.

How to capture input when debbuging in Visual Studio Code with .NET Core [duplicate]

VSCode Version: 1.8.0
OS Version: Win10 x64
Steps to Reproduce:
Create a new .net core cli app using "dotnet new"
Open the folder using VS code
Add two lines of code in Program.cs
string a = Console.ReadLine();
Console.WriteLine(a);
Switch to VS code debug window and start debugging, Debug Console window shows, and displays the first "Hello, World." output, and stops on the line of Console.ReadLine(), enter anything in the Debug Console and press Enter will be given err message of "Unable to perform this action because the process is running."
The question is how and where to enter text for Console.ReadLine() to accept during debugging, if I open a new cmd.exe and do a "dotnet run" it works fine, but in Visual Studio Code Debug Console it's not working.
To read input whilst debugging, you can use the console property in your configurations in launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"program": "${workspaceFolder}/bin/Debug/net5.0/your-project-name.dll",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"console": "integratedTerminal"
}
]
}
You can either use "externalTerminal" or "integratedTerminal". The "internalConsole" doesn't appear to be working.
I use the integratedTerminal setting, as the terminal is inside VSCode itself. You will now be able to read input with Console.ReadLine();
Note: Also, internalConsole doesn't work, and it is by design. The reason this is, is because internalConsole uses the Debug Console tab to show the output of the Console.WriteLine. Since the input box in the Debug Console is used to run expression on the current stack, there's no place to pass in input that will go to Console.ReadLine. That's the reason you'll have to use something like integratedTerminal.
The screenshot below shows that the VSCode team knows this -
i am pretty new to c#-visual studio debugger...
try setting a breakpoint before your
Console.Readline()
and debug it by stepping through your code F10 (not F11).
it should stop at
Console.Readline()
and wait for your input.

Error for 'program' in launch.json when debugging visual studio code

I use visual studio code and plugin for C# version 1.10.0-beta1.
When I try turn of debug, I get error:
launch: launch.json must be configured. Change 'program' to the path
to the executable file that you would like to debug.
I use ubuntu 17.04
My settings:
{
"window.menuBarVisibility": "toggle",
"csharp.fallbackDebuggerLinuxRuntimeId": "ubuntu.16.10-x64",
"omnisharp.useMono": true,
}
My configuration launch.json
{
"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,
"console": "internalConsole"
}
What should I write in: "program": ?
First, make sure you have built your program. Then, go to the root directory of your program and find your target-framework and project-name under Debug folder.
For example, you have built a hello world program named console1 and your .netcore version is 1.1.0, you will change "program":
"${workspaceRoot}/bin/Debug//"
to "program":
"${workspaceRoot}/bin/Debug/netcoreapp1.1/console1.dll".
And you can start your debugging now if you have installed the dotnet core debugger.

Categories

Resources