Skip to main content

Command Palette

Search for a command to run...

Difference between dotnet Restore, Build & Run ( 01-D)

Understand what happens when you run the 3 most used dotnet cli commands.

Updated
2 min read
Difference between dotnet Restore, Build &  Run ( 01-D)

Some developers struggle to understand what happens when you run these 3 commands. Understanding the difference let you made better decisions during the development workflow especially when creating a CI/CD pipeline to ship your code into different environment.

Dotnet Restore :

  • Downloads all the external packages (NuGet packages) your project depends on. Think of it like , Checking your shopping list and downloading everything from the store before you start cooking

    What it does:

    • Reads your .csproj or packages.config

    • Connects to NuGet

    • Downloads the required packages into your local machine (usually in ~/.nuget/packages/)

    • Usually happens automatically with dotnet build in .NET Core and later versions

Dotnet Build :

  • Compiles your project source code into a .dll or .exe file. Think of it like, Cooking the meal using the ingredients you got from the store.

    What it does:

    • Runs the compiler (Roslyn)

    • Turns your .cs files into IL (Intermediate Language)

    • Outputs into the /bin/Debug or /bin/Release folder

Dotnet Run

    • The dotnet run command builds and immediately executes your .NET application. Think of it like pressing the "Play" button in Visual Studio — your app compiles and launches

      What Happens When You Run

      It performs these steps under the hood:

      1. Restores NuGet packages (if needed)

      2. Builds the project (compiles code)

      3. Runs the app

C# Language And .Net

Part 2 of 5

This series contains all the core fundamentals and topics required to build a .net application. It will contain both theories and sample applications with automation testing.

Up next

Development Tools for building modern C# or .Net App & Most Used Cli Commands ( 01-C)

This article will look into tools required to build modern C# or .Net Application, where to download the tools and most used .net CLI commands.