Run a C# Project in Visual Studio Code

In this tutorial, you will learn how to run a C# console program in Visual Studio Code.

Step-by-Step Instructions#

Option 1. Using the Play Button#

  1. Open Visual Studio Code and open the folder containing your project.
  2. Open the main program file, usually Program.cs.
  3. Click the play button at the top-right corner.
  4. VS Code will build and run the program, and the Terminal panel will open automatically, showing the output.

Make sure you save your changes (File -> Save or Ctrl + S) to run the latest version of your program.

Option 2. Using the Terminal / .NET CLI#

  1. Open the Terminal:
    • Go to View -> Terminal.
    • Or press `Ctrl + `` (backtick).
  2. Verify that the terminal is in your project folder (the folder containing the *.csproj file):
    • If you are in the parent folder, use cd folder_name to navigate into the project folder.
    • If you are in a subfolder, use cd .. to move one folder up.
  3. Run the project with the command:
dotnet run
  1. VS Code will build and run the program, and the output will appear below the dotnet run command.

Make sure you save your changes (File -> Save or Ctrl + S) to run the latest version of your program.

Resources#