.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
dotnet -v
Display information on the installed version
New command
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 PalTrackerTests
will use the template "xUnit Test Project"dotnet new sln --name PalTracker
will use the template "Solution File"
Add command
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
dotnet sln
Examples:
dotnet sln PalTracker.sln add src/PalTracker/PalTracker.csproj
Run command
dotnet run
Examples:
dotnet run --project src/PalTracker
Publish command
dotnet publish
Examples:
dotnet publish src/PalTracker --configuration Release
Test command
dotnet test
Examples:
dotnet test test/PalTrackerTests --filter PalTrackerTests.InMemoryTimeEntryRepositoryTest
See also:
Tools
Last updated