dotnet CLI Overview

The dotnet CLI (or .NET CLI) is a command-line interface (CLI) is a new tool for developing the .NET application. It is a cross-platform tool and runs on Windows, MAC or Linux. In this tutorial, we will learn how to use .NET CLI to create, build and run a ASP.NET Core application.

Dotnet CLI

Dotnet CLI is a command line tool. It contains commands you can use to

  1. Create a new project
  2. Build a project
  3. Run the project
  4. Publish the project
  5. Restore Nuget Packages
  6. Migrate from one version to another version of .NET

Download & Installing dotnet cli

The Dot Net CLI is part of the .NET SDK. Hence install .NET SDK to install the .NET CLI, You can download & install NET SDK from this link.

The CLI installs side by side manner. We can install & use multiple versions of CLI Tools side by side.

Using dotnet CLI

The syntax of NET CLI consists of three parts. The “driver”, the “verb”, and the “arguments”

dotnet [verb] [arguments]

The driver is “dotnet”. It can either execute a command and run a application.

The “verb” is the command that you want to execute. The command performs an action.

The “arguments” are arguments that we pass to the commands invoked.

Commonly used Commands

Here are some of the most common dotnet cli commands.

newCreates a new project, configuration file, or solution based on the specified template.
restoreRestores the dependencies and tools of a project.
buildBuilds a project and all of its dependencies.
Packs the application and its dependencies into a folder for deployment to a hosting system.
runRuns source code without any explicit compile or launch commands.
test.NET test driver used to execute unit tests.
vstestRuns tests from the specified files.
packPacks the code into a NuGet package.
migrateMigrates a Preview 2 .NET Core project to a .NET Core SDK 1.0 project.
cleanCleans the output of a project.
slnModifies a .NET Core solution file.
helpShows more detailed documentation online for the specified command.
storeStores the specified assemblies in the runtime package store.

Creating a New ASP.NET Core project using dotnet CLI

Open the command prompt or Windows Powershell and create a Folder named “HelloWorld”

Dotnet new

dotnet new command creates a new project. The partial syntax is as follows



The project template to use when we invoke the command.


Forces content to be generated even if it would change existing files. This is required when the output directory already contains a project.

-i|–install <PATH|NUGET_ID>

Installs a source or template pack from the PATH or NUGET_ID provided.


Lists templates containing the specified name. If invoked for the dotnet new command, it lists the possible templates available for the given directory. For example, if the directory already contains a project, it doesn’t list all project templates.

-lang|–language {C#|F#|VB}

The language of the template to create. The language accepted varies by the template (see defaults in the arguments section). Not valid for some templates.

-n|–name <OUTPUT_NAME>

The name for the created output. If we do not specify the name, it will use the name of the current directory.


Location to place the generated output. The default is the current directory.


Prints out help for the command

The complete list of options for dotnet new is available here

Create a new Project using dotnet new

The following command creates a new dotnet project using the TEMPLATE

You can find out the list of template using

List of Templates

consoleConsole Application
classlibClass library
mstestUnit Test Project
xunitxUnit Test Project
webASP.NET Core Empty
mvcASP.NET Core Web App (Model-View-Controller)
razorASP.NET Core Web App
angularASP.NET Core with Angular
reactASP.NET Core with React.js
reactreduxASP.NET Core with React.js and Redux
webapiASP.NET Core Web API

To create an empty web application use the template web

The image below shows how you can create a new project using the template “web”

dotnet new

Restoring the Dependencies with dotnet restore

Once we created the new project, we have to download the dependencies. We can use the restore command

use –help to get help

Running the Application with dotnet run

Use dotnet run to start the application

dotnet run

Open localhost:5207/ in the browser and you should be able to see “Hello World”

dotnet new application running


We learned how to make use of dotnet CLI ( command-line interface). This tool is useful in MAC /Linux where IDE Like Visual studio is not available.

1 thought on “dotnet CLI Overview”

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top