Skip to main content

Command Palette

Search for a command to run...

.Net Cli

All essential .net CLI

Updated
•2 min read•View as Markdown
.Net Cli

The .Net command-line interface is a cross platform toolchain for developing, building, running, testing and publishing the .Net application.

The main advantage is that the command will remain the same in Windows, Linux and Mac OS. Whether you're building web APIs, desktop applications, or mobile apps, mastering these commands will streamline your workflow. Following are some of the other advantages of .Net CLI.

  1. It enables faster execution than GUI menus.

  2. It facilitates automation through scripting and CI/CD pipeline.

  3. CLI tool provide predictable behaviour across different environment such as docker.

  4. It provides more control and customization option.

  5. Its usage fosters deeper system understanding which a good developer always values.

Mostly used .Net CLI commands

dotnet --version: Displays the .NET SDK version for the current directory.

dotnet --list-sdks: Lists all installed .NET SDK versions and their installation paths.

dotnet --list-runtimes: Shows all installed .NET runtime versions, organized by framework type (e.g., Microsoft.NETCore.App, Microsoft.AspNetCore.App).

dotnet new --list: Shows all available project templates, including those from installed workloads and custom templates.

dotnet restore: It downloads and install all the Nuget or any package source package dependencies for a project.

dotnet nuget list source: Lists all configured NuGet package sources.

dotnet nuget add source <package_source_path>: Adds a new NuGet package source

dotnet nuget locals all --clear: Clears all NuGet caches, forcing fresh package downloads on next restore.

dotnet test: .NET test driver used to execute unit tests.

dotnet clean: Cleans the output of a project.

dotnet pack: Packs the code into a NuGet package.

dotnet build: Compiles the project and its dependencies into assemblies.

dotnet run: Executes the project, automatically restoring and building if needed.

dotnet publish: Prepares the application for deployment by copying all necessary files to an output folder.

More useful information from the official microsoft documentation: https://learn.microsoft.com/en-us/dotnet/core/tools/

.Net

Part 1 of 1

In this series, let's go through some of the basic concepts of modern .Net