Cheatsheet for dotnet CLI commands

few minutes

dotnet
cheatsheetdotnet

Beginner

developer

Info

dotnet --help, dotnet --info, dotnet --version

dotnet new list
dotnet new search <par-of-name> --author <part-of-author-name> --language <C# F# ...> --type <project or item> --tag <tag> --package <package-id>

New

dotnet new <template-name> -o <output-folder> --dry-run

  • sln, webapp, mvc, react, angular, razor, blazorserver, webapi, console, classlib, winforms, wpf, nunit, ...
Solution

dotnet sln list
dotnet sln add <project-path>
dotnet sln remove <project-path>

Project

dotnet restore
dotnet list package/reference
dotnet add/remove package/reference <package-name or another-project>
dotnet remove package/reference <package-name or another-project>

Run

dotnet clean
dotnet build dotnet build -c Release
dotnet publish -o <output-folder> dotnet run <path-to-app-dll>

Test

dotnet test
dotnet test -t
dotnet test --filter "Priority=1&(TestCategory=Sales)"

  • = != ~ !~
  • | &
  • NUnit: FullyQualifiedName, Name, Priority, TestCategory
  • xUnit: FullyQualifiedName, DisplayName, Traits
  • MSTest: FullyQualifiedName, Name, ClassName, Priority, TestCategory

dotnet test -l console -l "html;LogFileName=results.html" -l "trx;LogFileName=results.trx"
dotnet test -e VAR1=abc -s <settings-file>

Package

dotnet pack -c Release dotnet nuget push

Tools

dotnet tool list -g [--local]
dotnet tool search <term>
dotnet tool install <tool-name> --tool-path c:\dotnet-tools
dotnet tool uninstall <tool-name>
dotnet tool update <tool-name>
dotnet tool restore dotnet tool run <cmd> <arg>

dotnet dev-certs
dotnet fsi
dotnet user-jwts
dotnet user-secrets
dotnet watch