OSC#.001: .NET SDK and Compiler — Install, Verify, Create, Build, Run, and Understand the C# Toolchain

Original technical cover showing C# source code, dotnet CLI commands, and a simplified source-to-Roslyn-to-runtime pipeline.

Elementary Overview

C# source code does not run by itself. You need a toolchain that can understand the source, build it into .NET output, and run the resulting application. For a modern C# developer, the center of that toolchain is the .NET SDK. The SDK gives you the dotnet command, project templates, the build system, the C# compiler, package tooling, and the pieces needed to create and run .NET applications.

This first C# lesson connects directly to OSDotNet.001: What Is .NET? and OSDotNet.002: What the Common Language Runtime Does. It also builds on the practical idea behind PATH: when you type dotnet in a terminal, the operating system must be able to find the installed executable.

What You Should Learn

  • What the .NET SDK contains and how it differs from the .NET runtime.
  • How to verify that the SDK is installed and visible on your PATH.
  • How to create a console project with dotnet new.
  • What Program.cs and the project file do at a beginner level.
  • How dotnet build invokes the C# compiler and produces build output.
  • How dotnet run builds and executes an application.
  • What Roslyn, IL, metadata, and the .NET runtime are doing in the simplified compilation pipeline.
  • How to diagnose the first common SDK and build failures.

Start With The .NET SDK

The .NET runtime is enough to run compatible applications, but the .NET SDK is what you normally install when you want to develop C# software. Microsoft describes the .NET CLI as a cross-platform toolchain included with the SDK for developing, building, running, and publishing .NET applications. Installing an SDK also installs its corresponding runtime.

After installing the SDK for your operating system, open a new terminal and verify it before you start writing code.

dotnet --info

dotnet --list-sdks

dotnet --version

dotnet --info gives a broad environment report. dotnet --list-sdks shows the installed SDK versions. dotnet --version reports the SDK version selected for the current environment. If the shell says that dotnet is not found, verify the installation and your PATH configuration before troubleshooting C# source code.

.NET — “Let’s Learn .NET: C#.” A beginner session that introduces C#, .NET, the tools used to get started, and the first development workflow.

Create Your First C# Project

The .NET SDK includes a template engine. The command dotnet new console creates a console application from the installed console template. You can create the project in a new directory with:

dotnet new console -n HelloCSharp
cd HelloCSharp

A simple project normally includes Program.cs, which contains C# source code, and a .csproj project file, which tells the .NET build system important things such as the SDK style and target framework. As the project grows, the project file can also record package references and other build settings.

Modern console templates can be very small. You may see a one-line program such as:

Console.WriteLine("Hello, World!");

That is valid modern C#. Top-level statements let beginners write executable code without manually declaring a namespace, class, and Main method first. Later lessons will explain the syntax and program structure in detail. If you use an editor such as Visual Studio Code, syntax highlighting and a monospace font can make source code easier to read, but the compiler does not care about those visual editor choices.

.NET — “Hello World! | C# for Beginners.” Scott Hanselman and David Fowler create and run a first C# console application in Visual Studio Code.
Original diagram showing Program.cs flowing through dotnet build, the .NET SDK, the Roslyn C# compiler, IL and metadata, and the .NET runtime, with common dotnet CLI commands below.
Original BitcoinVersus.Tech diagram: a simplified first-lesson view of how C# source moves through the .NET SDK and compiler into a runnable application.

Build The Project

Run:

dotnet build

At a high level, the SDK coordinates restore and build work, MSBuild evaluates the project, and the C# compiler processes the source. Microsoft’s C# compiler platform is commonly called Roslyn. The compiler parses the code, checks syntax and meaning, and produces .NET output containing Intermediate Language (IL) and metadata when the build succeeds.

Microsoft’s dotnet build documentation notes that normal build output can include the main assembly, debugging symbols, dependency information, runtime configuration, and referenced libraries. For a beginner console project, you will commonly see generated folders such as obj for intermediate build data and bin for build output.

dotnet build

# Example success pattern:
# Build succeeded.
#     0 Warning(s)
#     0 Error(s)

Understand The Compiler Pipeline

A useful beginner model is:

C# source (.cs)
      ↓
.NET SDK / build system
      ↓
Roslyn C# compiler
      ↓
IL + metadata in an assembly
      ↓
.NET runtime
      ↓
running program

This model is intentionally simplified. The runtime may use just-in-time compilation, ahead-of-time compilation, or other execution strategies depending on how the application is built and deployed. For the first lesson, the key distinction is enough: the C# compiler translates your source into .NET program output, and the .NET runtime is responsible for executing that output. For a deeper runtime explanation, revisit OSDotNet.002.

Run The Application

For normal development, the simplest command is:

dotnet run

dotnet run is designed for the development loop. It runs source code without requiring you to type a separate explicit compile and launch sequence. If the project needs to be built first, the command handles that work as part of the run process.

You can also build first and then run the resulting application output separately. That distinction becomes more important later when you learn deployment, publishing, build configurations, and continuous integration.

Microsoft Developer — “No projects just C# with dotnet run app.cs.” Damian Edwards demonstrates the modern .NET CLI and the newer file-based C# workflow, plus how it can grow into a normal project when project features are needed.

Project-Based And File-Based C#

Modern .NET also supports file-based apps for small programs and experiments. In supported SDK versions, a single C# source file can be run directly, reducing project ceremony for quick work. Microsoft’s current beginner documentation shows a file-based workflow as well as project-based development.

dotnet hello-world.cs

Do not let that convenience blur the main lesson. Larger applications still benefit from project files because projects define framework targets, package references, build behavior, and other settings. Learn the project-based workflow first, then treat file-based apps as another tool in the same SDK.

r/dotnet discussion: a beginner asks how C# is compiled and run from the command line. The replies point directly to the .NET SDK, the CLI toolchain, and dotnet run.

The First Troubleshooting Order

  1. Can the shell find dotnet? Run dotnet --info.
  2. Is an SDK actually installed? Run dotnet --list-sdks.
  3. Are you in the project directory? Confirm that the .csproj file is present before running project commands.
  4. Does the project build? Run dotnet build and read the first useful compiler error rather than only the final error count.
  5. Did restore fail? Check network access, package sources, and package/version errors.
  6. Is the wrong SDK being selected? Compare dotnet --info, dotnet --list-sdks, target framework settings, and any global.json file.
  7. Did you change the source? Save the file, rebuild, and confirm you are running the intended project.

Mini Lab

  1. Run dotnet --info and identify the SDK version and operating system information.
  2. Run dotnet --list-sdks and note whether more than one SDK is installed.
  3. Create a project with dotnet new console -n FirstCSharpLab.
  4. Enter the directory with cd FirstCSharpLab.
  5. Open Program.cs and change the message.
  6. Run dotnet build.
  7. Run dotnet run.
  8. Find the bin and obj directories created by the build.
  9. Introduce one deliberate syntax error, build again, read the compiler diagnostic, then fix the error.

Knowledge Check + Answers

  1. What is the difference between the .NET SDK and the .NET runtime? The runtime executes .NET applications; the SDK adds the development tools needed to create, build, test, package, and run them.
  2. Which command gives a broad report about the installed .NET environment? dotnet --info.
  3. Which command creates a console project? dotnet new console.
  4. What does dotnet build do? It builds the project and its dependencies, invoking the .NET build system and compiler to produce application output.
  5. What is Roslyn? Microsoft’s open-source .NET compiler platform that includes the C# compiler and compiler APIs.
  6. What does the C# compiler produce in the normal managed build model? .NET assemblies containing IL and metadata, plus related build artifacts.
  7. What does dotnet run do? It builds as needed and runs the application from source during development.
  8. Why can a correct SDK installation still produce “dotnet not found”? The shell may not be able to find the executable because PATH or the terminal environment is wrong or stale.

Primary References

Elementary Review

Your first C# skill is not memorizing syntax. It is proving that the toolchain works. Install the .NET SDK, verify it with dotnet --info, create a project with dotnet new, build it with dotnet build, and run it with dotnet run. Once that loop works, every later C# lesson has a reliable place to start.

Editor’s Note

The featured image is an original 1200×630 BitcoinVersus.Tech cover created specifically for OSCSharp.001 and is not reused in the body. The lesson uses a separate original 1200×675 instructional build-pipeline diagram. The three YouTube videos use responsive native Gutenberg 16:9 embed blocks, and the social item uses a responsive native Gutenberg embed. Ordinary lesson prose is not placed inside bordered, shaded, card, callout, panel, or fixed-width text boxes.

BitcoinVersus.Tech content is provided for informational and educational purposes.

Leave a Reply