Command line quick reference for .NET 11
Author: Areg Sarkissian
Introduction
In this post I describe some of the .NET CLI commands for installing .NET 11 project templates and global .NET tools that are useful for creating projects and solutions and for generating design time artifacts such as database migrations.
Install the .NET 11 SDK
Run the .NET 11 installer for your platform.
Once installed here are some of the basic things you can do with dotnet command.
dotnet new commands
# Check latest installed .NET version
dotnet --version
# list all built in and downloaded template package templates
dotnet new list
# list only the downloaded template packages and the templates contained within them
# prints out the uninstall command for each downloaded template package
dotnet new uninstall
# uninstall the downloaded template package
# we can uninstall template packages, not individual templates within a template package
dotnet new uninstall <template package>
#examples
dotnet new uninstall Aspire.ProjectTemplates
dotnet new uninstall xunit.v3.templates
# search for a available template packages
dotnet new search --package <search keyword>
# search for a available templates and their corresponding packages
dotnet new search <search keyword>
# install a template package
dotnet new install <template package>
# check template packages for update status
dotnet new update --check-only
# example output for: dotnet new update --check-only
An update for template packages is available:
Package Current Latest
----------------------- ------- ------
Aspire.ProjectTemplates 13.5.3 13.6.5
xunit.v3.templates 4.0.2 4.0.3
# update all template packages
dotnet new update
# xUnit v3 support is natively built into the .NET 11 SDK
# using the xunit project template create an xunit v3 test project with project name MyProject.Tests
dotnet new xunit --xunit-version v3 -n tests/MyProject.Api.Tests
dotnet tool commands
# list all globally installed tools (includes Package Id and tool name)
# the commands are prefixed with dotnet-. So for example the ef command will be listed as dotnet-ef
dotnet tool list --global
#example output:
Package Id Version Commands
--------------------------------------
dotnet-ef 11.0.0 dotnet-ef
# uninstall an installed tool
# tool name is the Package Id from the dotnet tool list --global command
dotnet tool uninstall --global <tool name>
#example uninstall the globally installed EF core tool
dotnet tool uninstall --global dotnet-ef
# globally update or install a tool
# dotnet tool update will run dotnet tool install if the tool is not already installed otherwise will update it
dotnet tool update --global <tool name> --version <version number>
dotnet tool update --global <tool name> # installs latest version
# example updating the EF Core tool
dotnet tool update --global dotnet-ef
# global tools are installed in $HOME/.dotnet/tools
# so dotnet tool update --global dotnet-ef installs a tool named dotnet-ef at:
# $HOME/.dotnet/tools/dotnet-ef
# execute a tool
# tool command name is the tool command from the dotnet tool list --global command
# with the dotnet- prefix removed.
dotnet <tool command name>
# so for example the ef tool installed at $HOME/.dotnet/tools/dotnet-ef will have command name ef.
dotnet ef
# check the ef core tool version
dotnet ef --version