How to create a C# Console Application in Visual Studio Code and Debug

Create a new console application

Daneesha Bartholomeusz
2 min readMar 19, 2022

Open Visual Studio Code and from the top menu select Terminal -> New Terminal to open a new terminal.

Navigate to the folder you want to create your project in and type this command.

dotnet new console -o "ConsoleApplciation2"

Navigate to the newly created folder.

cd ConsoleApplication2

Open the code of the new project by typing this command.

code .

This will open up the new code in a new screen.

Get another new terminal and type this command.

dotnet restore

Type

dotnet run

and your project will run.

Debugging

The first time you open a Program.cs file it will prompt you to add missing assets to build and debug your application. (see the screenshot from the one before the last).

Select Yes.

If you haven’t installed Omnisharp before it will get installed.

On the left navigation menu select the Debugger icon.

On the Add Configuration drop down list select .NET Core Launch (console).

Add a debug point to a line on the left hand side margin.

Click on Run → Debug on the top menu.

The application will run in debug mode and you can step over etc. and do your debugging.

--

--

No responses yet