Run a C# Project in Visual Studio Code

This procedure walks you through running a C# console program in Visual Studio Code.


🧰 Prerequisites

Install all four before continuing. The steps below assume they are already set up.

📋 Steps

  1. Open the built-in terminal using the menu View → Terminal.

  2. Make sure the terminal is in the project folder. The last folder in the terminal prompt should match the project folder name.

  3. If it’s not, navigate to it with cd folder-name.

  4. Run the program with: dotnet run.

🎯 Expected Outcome

The program output appears in the terminal directly below the dotnet run command.

⚠️ Mistakes

Forgetting to save before running

dotnet run compiles the files on disk, not what is currently in the editor. If changes are made but not saved, the program runs the previous version. Always save with Ctrl+S (Windows/Linux) or Cmd+S (Mac) before running.

Running from the wrong folder

dotnet run must be executed from the folder that contains the .csproj file. If the terminal is in a parent folder or subfolder, the command fails with an error like Couldn't find a project to run. Use cd folder-name to navigate into the correct folder.

📚 Resources