.NET CLI
dotnetCLI for solutions, projects, templates.
Solutions
New solution (modern format):
dotnet new sln -n MySolution --format slnxAdd single project:
dotnet sln MySolution.sln add ./src/MyProject/MyProject.csprojAdd all projects recursively:
dotnet sln MySolution.sln add **/*.csproj
Projects
Class library:
dotnet new classlib -n MyLibrary -o ./src/MyLibraryConsole app:
dotnet new console -n MyApp -o ./src/MyAppWeb API:
dotnet new webapi -n MyApi -o ./src/MyApiList templates:
dotnet new list
Restore / build / run
Restore deps:
dotnet restoreBuild:
dotnet buildRun:
dotnet runWatch (auto-rebuild on change):
dotnet watch runPublish (framework-dependent):
dotnet publish -c Release -o ./publishSelf-contained:
dotnet publish -c Release -r linux-x64 --self-contained true
Package management
Add package:
dotnet add package SerilogSpecific version:
dotnet add package Serilog --version 3.1.1Remove:
dotnet remove package SerilogList installed:
dotnet list packageOutdated:
dotnet list package --outdated
Project references
Add reference between projects:
dotnet add MyApi reference MyDomainRemove:
dotnet remove MyApi reference MyDomain
Tests
Run:
dotnet testFilter:
dotnet test --filter "FullyQualifiedName~MyTests"With coverage:
dotnet test --collect:"XPlat Code Coverage"
SDK info
- Versions:
dotnet --versiondotnet --list-sdksdotnet --list-runtimes