.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.
Content
General commands
Command | Action |
---|---|
| Display information on the installed version |
New command
Command | Action |
---|---|
| View the available templates (see docs.microsoft.com) |
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 PalTrackerTests
will use the template "xUnit Test Project"dotnet new sln --name PalTracker
will use the template "Solution File"
Add command
Command | Action |
---|---|
| Adds project-to-project (P2P) references (see docs.microsoft.com) |
| Adds a package reference to a project file (see docs.microsoft.com) |
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 |
---|---|
| Modifies a .NET Core solution file (see docs.microsoft.com) |
Examples:
dotnet sln PalTracker.sln add src/PalTracker/PalTracker.csproj
Run command
Command | Action |
---|---|
| Runs source code without any explicit compile or launch commands (see docs.microsoft.com) |
Examples:
dotnet run --project src/PalTracker
Publish command
Command | Action |
---|---|
| Packs the application and its dependencies into a folder for deployment to a hosting system (see docs.microsoft.com) |
Examples:
dotnet publish src/PalTracker --configuration Release
Test command
Command | Action |
---|---|
| Run the tests (see docs.microsoft.com) |
Examples:
dotnet test test/PalTrackerTests --filter PalTrackerTests.InMemoryTimeEntryRepositoryTest
See also:
Tools
Last updated