To write, compile, and run C# programs you need two things: the .NET SDK (the tools that compile and run your code) and an editor or IDE where you can write that code comfortably. In this lesson we'll install and configure both, learn the basic commands of the dotnet command-line tool, and confirm that everything works by creating and running a test project. This is the essential step before we can move on, in the next lesson, to BiblioTech's first real program.

Contents

  1. Installing the .NET SDK
  2. Choosing an editor or IDE
  3. The structure of a console project created with dotnet new console
  4. Basic dotnet CLI commands
  5. Verifying that the environment works

Installing the .NET SDK

The .NET SDK (Software Development Kit) is the set of tools needed to build and run .NET applications, including programs written in C#. It includes:

  • The C# compiler (which translates your source code into intermediate language, IL).
  • The .NET runtime (the engine that runs that code, including the garbage collector and the JIT compiler mentioned in the previous lesson).
  • The dotnet CLI, a command-line tool for creating, building, running, and managing projects.

Steps to install the SDK

  1. Visit the official .NET downloads page (dotnet.microsoft.com/download).
  2. Download the latest LTS (Long Term Support) version. LTS versions receive updates and support for a longer period, making them the safest choice for learning and for real projects.
  3. Run the installer for your operating system (Windows, macOS, or Linux). The process is the usual one: next, accept, install.
  4. Restart your terminal (or the computer itself, if the installer tells you to) so the system changes take effect.

Checking the installation

Once installed, open a terminal (Command Prompt, PowerShell, or a Linux/macOS terminal) and run:

dotnet --version

Note: although this command isn't C# code, throughout this course we'll show terminal commands in code blocks so you can visually tell them apart from regular text.

If the installation went well, you'll see a version number such as 8.0.100 or similar. If instead you get a "command not found" error, check that the installation completed correctly and that the terminal was restarted.

You can also request more detailed information about the installed environment:

dotnet --info

This command shows the SDK version, the installed runtimes, and the detected operating system. It's very useful when you need to diagnose installation problems.

Choosing an editor or IDE

With the SDK installed you can already compile C# code, but writing it in a plain text editor would be quite uncomfortable: no autocomplete, no error detection as you type, no debugging support. That's why it's recommended to use a specialized editor or an IDE (Integrated Development Environment). Here are the three most common options:

Tool Type Strengths When to choose it
Visual Studio Code + C# Dev Kit Lightweight editor + extension Free, fast, cross-platform, highly extensible Learning, small and medium projects, anyone already using VS Code
Visual Studio (Community/Professional) Full IDE Advanced visual tools (form designer, very powerful debugger) Windows, desktop applications (WPF/Windows Forms), large projects
JetBrains Rider Full IDE Excellent refactoring, widely used by professional teams, cross-platform Anyone already familiar with other JetBrains IDEs, professional projects

There's no single "correct" option: all three let you write and run C# perfectly well. In this course, the examples work the same regardless of your choice; we'll always use the dotnet CLI to create and run projects, so the steps are identical no matter which editor you use.

Visual Studio Code with C# Dev Kit

Visual Studio Code (VS Code) is a lightweight, free code editor. On its own it doesn't understand C#; for that you install the official C# Dev Kit extension, which adds:

  • Syntax highlighting and smart autocomplete.
  • Error detection as you type (even before compiling).
  • A built-in debugger to step through your code.
  • Browsing of .NET projects and solutions right from the editor.

To install it: open VS Code, go to the extensions panel (the puzzle-piece icon in the sidebar), search for "C# Dev Kit", and install it with the corresponding button.

Visual Studio

Visual Studio is Microsoft's historic IDE for C# development, especially powerful on Windows. The Community edition is free for students, open-source projects, and small teams. When installing it, the installer lets you choose "workloads"; for this course, the ".NET desktop development" or ".NET cross-platform development" workload would be enough.

JetBrains Rider

Rider is a paid IDE (with a free trial period) developed by JetBrains, the same company behind IntelliJ IDEA. It's cross-platform (Windows, macOS, Linux) and highly regarded in professional environments for its refactoring and code analysis capabilities.

The structure of a console project created with dotnet new console

The dotnet CLI lets you create new projects from templates. The console template generates a console application project, the simplest type of project and the one we'll work with for a good part of this course. To create one:

dotnet new console -o MyProject

The -o (for output) parameter specifies the name of the folder where the project will be created. Running this command makes dotnet generate the following file structure:

MyProject/
├── MyProject.csproj
├── Program.cs
└── obj/

Let's understand what each element is:

Element What it is
MyProject.csproj The project file. An XML file describing how to build the project: which .NET version is used, project type, references to external packages, etc.
Program.cs The main source code file. This is where we'll write our C# code. By default it already contains a sample "Hello World".
obj/ A folder generated automatically with intermediate build files. It's not edited by hand; it can be safely deleted, since it regenerates itself.

The first time you build the project, a bin/ folder will also appear, containing the already compiled program, ready to run.

A quick look at the contents of the generated .csproj (no need to understand it all yet):

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net8.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

</Project>
  • OutputType>Exe indicates that the build output is an executable (a program that can be launched), rather than, say, a library.
  • TargetFramework>net8.0 indicates which version of .NET the project uses to build and run.
  • ImplicitUsings and Nullable are modern settings that simplify the code; we'll come to understand them little by little throughout the course (implicit usings are covered in the basic syntax lesson, and nullability is introduced in the variables and data types lesson).

Basic dotnet CLI commands

Here are the dotnet commands you'll use constantly throughout the course:

Command What it does
dotnet new console -o ProjectName Creates a new console project in the given folder
dotnet restore Downloads and prepares the dependencies (packages) the project needs
dotnet build Compiles the project (generates the executable) without running it
dotnet run Compiles (if needed) and runs the project in a single step
dotnet --version Shows the installed SDK version
dotnet --info Shows detailed information about the installed .NET environment

In day-to-day practice, the command you'll use the most is dotnet run, since it builds and runs in a single step. The dotnet build and dotnet restore commands are useful when you want to keep those steps separate, for example in an automated continuous integration pipeline.

Complete workflow example

dotnet new console -o BiblioTechConsole
cd BiblioTechConsole
dotnet run

This workflow creates the project, moves into its folder, and runs it directly. Since the project generated by the template already includes a sample "Hello World", you'll see something like:

Hello, World!

In the next lesson we'll create exactly this project, name it BiblioTechConsole, and modify its contents to work with our own message.

Verifying that the environment works

Before continuing with the course, it's important to confirm everything is correctly installed. Follow this checklist:

  1. Run dotnet --version in a terminal and confirm that a version number appears (for example, 8.0.100), with no errors.
  2. Create a test project with dotnet new console -o EnvironmentTest.
  3. Go into the generated folder (cd EnvironmentTest) and run it with dotnet run.
  4. Confirm that the Hello, World! message (or similar) appears in the terminal, with no build errors.
  5. Open the project folder with your chosen editor (VS Code, Visual Studio, or Rider) and confirm that the Program.cs file opens with C# syntax highlighting and, if you've installed the corresponding extension or workload, with autocomplete.
  6. Once you've confirmed everything works, you can delete the EnvironmentTest folder: it was just a test.

If all these steps work without errors, your environment is ready for the rest of the course.

Common Mistakes and Tips

  • Forgetting to restart the terminal after installing the SDK: on many systems, the terminal needs to be restarted (or the system itself, on Windows) to recognize the new dotnet command. If dotnet --version doesn't work right after installing, try closing and reopening the terminal before digging any further.
  • Confusing dotnet build with dotnet run: build only compiles (it generates the executable but doesn't launch it); run compiles and also runs it. If you expect to see the program's output on screen, you need dotnet run.
  • Installing only the runtime instead of the SDK: there are separate downloads for "runtime" (only for running already-compiled programs) and "SDK" (for building and running). To develop, you need the SDK, not just the runtime.
  • Mixing .NET versions unnecessarily: when starting out, there's no need to install several SDK versions at once. Install the latest LTS version and use it throughout the course, unless told otherwise.
  • Tip: whichever editor you choose, spend a few minutes getting familiar with its file explorer and its integrated terminal; you'll use them constantly throughout the course.

Exercises

  1. Install the .NET SDK (if you don't already have it) following the steps in this lesson, and run dotnet --version and dotnet --info. Note down what SDK version and what operating system the second command reports.

  2. Create a test console project named EnvironmentTest with dotnet new console. Without opening any editor yet, use your system's file explorer (or the ls/dir command) to examine what files and folders were generated, and match them against the table in this lesson.

  3. Run the EnvironmentTest project with dotnet run. Then open the Program.cs file with the editor you chose and change the text "Hello, World!" to a different message, for example "BiblioTech environment ready!". Run dotnet run again and confirm the new message appears on screen.

Solutions

  1. The output will vary depending on your machine, but a typical example would be: dotnet --version8.0.100; dotnet --info showing the installed SDK, the operating system (for example, Linux or Windows), and the architecture (x64, arm64, etc.). If the command fails, review the installation by following the steps in this lesson again.

  2. Creating the project generates, at minimum, EnvironmentTest.csproj (the project file) and Program.cs (source code), and after the first build an obj/ folder will also appear (and, after running, bin/). This matches the structure described in the "Structure of a console project" section.

  3. After changing the line in Program.cs (something like Console.WriteLine("BiblioTech environment ready!");) and running dotnet run again, the terminal should show: BiblioTech environment ready!. This confirms that the editor, the SDK, and the dotnet CLI are all working correctly together.

Conclusion

In this lesson you set up your complete development environment: the .NET SDK, an editor or IDE of your choice, and the basic dotnet CLI commands (new, build, run, restore). You also learned the minimal structure of a console project and confirmed, step by step, that everything works correctly.

With the environment ready, in the next lesson, Hello World Program, we'll create the course's first real project — BiblioTechConsole — and analyze each part of the code line by line, including both the classic form and the modern (top-level statements) form of writing it.

© Copyright 2026. All rights reserved