.NET CLI

The .NET command-line interface (CLI) is a cross-platform toolchain for developing, building, running, and publishing .NET applications. The .NET CLI is included with the .NET SDK.

→ docs, code

Content

General commands

Command
Action

dotnet -v

Display information on the installed version

New command

Command
Action

dotnet new

Examples:

  • dotnet new webapi --output src/PalTracker --name PalTracker will use the template "ASP.NET Core Web API"

  • dotnet new xunit --output test/PalTrackerTests --name PalTrackerTestswill use the template "xUnit Test Project"

  • dotnet new sln --name PalTracker will use the template "Solution File"

Add command

Command
Action

dotnet add reference

dotnet add package

Examples:

  • dotnet add test/PalTrackerTests reference src/PalTracker/PalTracker.csproj

  • dotnet add test/PalTrackerTests package Microsoft.AspNetCore.TestHost --version 2.2.0

Solution command

Command
Action

dotnet sln

Examples:

  • dotnet sln PalTracker.sln add src/PalTracker/PalTracker.csproj

Run command

Command
Action

dotnet run

Examples:

  • dotnet run --project src/PalTracker

Publish command

Command
Action

dotnet publish

Examples:

  • dotnet publish src/PalTracker --configuration Release

Test command

Command
Action

dotnet test

Examples:

  • dotnet test test/PalTrackerTests --filter PalTrackerTests.InMemoryTimeEntryRepositoryTest

See also:

Tools

Last updated