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.
Related
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.
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"
}
]
}
After installing Vscode, I did the following:
I opened an empty folder in vscode.
Added C# for visual studio code.
I entered the dotnet new console command in the terminal to create bin, obj folder, .csproj file, and Program.cs file.
Click .Net Generate Assets for Build and Debug on the Command Palette and generate a .vscode containing launch.json and tasks.json files.
I changed the "console" part of the launch.json file to externalTerminal.
In my workspacce, I created one more c# file named test.
After that, when I tried to run the test.cs file, CS0017 error occurred. Later, when I renamed the Main method to something else in the test file, the error disappeared. However, when I ran the test file, it was the Program.cs file created with the dotnew new console command. I searched on Google to find out how to do it and reinstalled Vscode, but couldn't fix it.
Here is the Program.cs file and test.cs file and launch.json file
Program.cs
using System;
namespace ProgramFile
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World! Program");
Console.ReadKey();
}
}
}
test.cs
using System;
namespace testFile
{
class test
{
static void Main(string[] args)
{
Console.WriteLine("Hello World! Test");
Console.ReadKey();
}
}
}
launch.json
{
// 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 (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/Vscode.Workspace.dll",
"args": [],
"cwd": "${workspaceFolder}",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "externalTerminal",
"stopAtEntry": false
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
}
My VSocde
My Vscode picture please take a look
Is there a way to create multiple C# files in one workspace and run only the files you want to run each time?
Go to Project -> Properties -> Application Tab -> Startup object
I installed VS Code and created a simple C# source. After installing OmniSharp and .Net Debugger extension, I want to start debugging the code.
VS Code asks me to Select Environment and by default there are Node.js and .Net Core.
I selected More... from the drop-down menu and tried to find an environment for standard .net framework (I mean the non-core version) but could not find any.
Does this mean VS Code only supports .NET Core?
For whatever reason, non-core .NET functionality is nowhere to be found in any of the GUI drop downs on my configuration, while your mileage may vary in that respect, directly editing launch.json always works. To convert an auto-generated dotnet core debug config to use non-core .NET, simply change the line "type":"coreclr" to "type":"clr". Here's an example configuration:
{
"name": ".NET Launch (console)",
"type": "clr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/Project/bin/Debug/net461/Project.exe",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"console": "internalConsole"
},
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.