Command-Lines
To make it easier to enter commands at the prompt, this page lists all commands as a single line that can be copied and pasted.
- Chapter 1 - Introducing Apps and Services with .NET
- Page 19 - Managing VS Code extensions at the command prompt
- Page 20 - Using other project templates
- Page 25 - Defining project properties to reuse version numbers
- Page 40 - Installing Docker and an SQL Server container image
- Page 42 - Running the SQL Server container image
- Page 50 - Removing Docker resources
- Page 50 - Setting up the EF Core CLI tool
- Page 52 - Creating a class library for entity models
- Page 58 - Setting the user and password for SQL Server authentication
- Page 66 - Getting help for the dotnet tool
- Chapter 2 - Buildling Mobile Apps Using .NET MAUI
- Chapter 3 - Building Desktop Apps Using Avalonia
- Chapter 4 - Building Web Apps Using Blazor
- Chapter 9 - Building an LLM-Based Chat Service
- Chapter 10 - Building and Securing Web Services Using Minimal APIs
- Chapter 11 - Caching, Queuing, and Resilient Background Services
- Chapter 12 - Broadcasting Real-Time Communication Using SignalR
- Chapter 13 - Combining Data Sources Using GraphQL
- Chapter 14 - Building Efficient Microservices Using gRPC
code --list-extensionscode --install-extension ms-dotnettools.csdevkitListing all installed project templates:
dotnet new listInstalling a new project template:
dotnet new --install "Vue.Simple.Template"After making changes, at the terminal or command prompt, run the following command:
dotnet restorePull down the latest container image for SQL Server 2025, as shown in the following command:
docker pull mcr.microsoft.com/mssql/server:2025-latestRun the container image for SQL Server with a strong password and name the container nw-container, as shown in the following command:
docker run --cap-add SYS_PTRACE -e 'ACCEPT_EULA=1' -e 'MSSQL_SA_PASSWORD=s3cret-Ninja' -p 1433:1433 --name nw-container -d mcr.microsoft.com/mssql/server:2025-latestAsk Docker to list all containers, both running and stopped, as shown in the following command:
docker ps -aStop the nw-container container, as shown in the following command:
docker stop nw-containerRemove the nw-container container, as shown in the following command:
docker rm nw-containerRemove the image to release its disk space, as shown in the following command:
docker rmi mcr.microsoft.com/mssql/server:2025-latestCheck if you have already installed dotnet-ef as a global tool, as shown in the following command:
dotnet tool list --globalIf an old version is installed, then update the tool, as shown in the following command:
dotnet tool update --global dotnet-efIf it is not already installed, then install the latest version, as shown in the following command:
dotnet tool install --global dotnet-efTo update to the latest .NET 11 preview or release candidate version (which will be available from February 2026 to October 2026), use the following command with a version wildcard:
dotnet tool update --global dotnet-ef --version 11.0-*You can also remove the tool, as shown in the following command:
dotnet tool uninstall --global dotnet-efGenerate entity class models for all tables, as shown in the following command:
dotnet ef dbcontext scaffold "Data Source=tcp:127.0.0.1,1433;Initial Catalog=Northwind;User Id=sa;Password=s3cret-Ninja;TrustServerCertificate=true;" Microsoft.EntityFrameworkCore.SqlServer --namespace Northwind.EntityModels --data-annotationsCommon connection strings
Local SQL Server (default instance):
"Data Source=.;Initial Catalog=Northwind;Integrated Security=true;TrustServerCertificate=true;"
Local SQL Server (replace <your_instance_name> with named instance):
"Data Source=.\<your_instance_name>;Initial Catalog=Northwind;Integrated Security=true;TrustServerCertificate=true;"
Azure SQL Database (replace <your_server_name>, <your_user_name>, and <your_password>):
"Data Source=tcp:<your_server_name>.database.windows.net,1433;Initial Catalog=Northwind;User ID=<your_user_name>;Password=<your_password>;Persist Security Info=False;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;"
Set the two environment variables at the command prompt or terminal, as shown in the following commands:
- On Windows:
setx MY_SQL_USR <your_user_name>
setx MY_SQL_PWD <your_password>- On macOS and Linux:
export MY_SQL_USR=<your_user_name>
export MY_SQL_PWD=<your_password>Getting help for a dotnet command like build in a web browser:
dotnet help build
Getting help for a dotnet command like build at the command prompt:
dotnet build -?
To see which workloads are currently installed, enter the following command:
dotnet workload listTo install the .NET MAUI workloads for all platforms, enter the following command at the command line or terminal:
dotnet workload install mauiTo update all existing workload installations, enter the following command:
dotnet workload updateTo add missing workload installations required for a project, in the folder containing the project file, enter the following command:
dotnet workload restore <projectname>To remove leftover and unneeded workloads, as shown in the following command:
dotnet workload cleanYou can create this item using the CLI, as shown in the following command:
dotnet new maui-page-xaml --name SettingsPage.xamlYou can create this item using the CLI, as shown in the following command:
dotnet new maui-dict-xaml --name Northwind.xamlTo install the Avalonia project templates, as shown in the following command:
dotnet new install Avalonia.TemplatesCreate a new project using the Blazor Web App project template:
dotnet new blazor --interactivity None -o Northwind.Blazor
Start the Northwind.Blazor project, using its https profile without debugging:
dotnet run --launch-profile httpsTo install the AI Chat Web App project template, at the command prompt or terminal, enter the following command:
dotnet new install Microsoft.Extensions.AI.TemplatesAdd a user secrets entry for your OpenAI key, as shown in the following command:
dotnet user-secrets set OpenAi:Key <your-OpenAI-key>To quickly download and run an Ollama model in interactive mode, use the following command:
ollama run <model>To check its version, as shown in the following command:
ollama --versionTo pull down a named model like Meta’s Llama3 or Google’s Gemma3, as shown in the following command:
ollama pull gemma3:1bTo list the available local models:
ollama listTo run a named model (which will also download it if not already pulled), as shown in the following command:
ollama run gemma3:1bCreate a local JWT, as shown in the following command:
dotnet user-jwts createPrint all the information for the ID that was assigned, as shown in the following command:
dotnet user-jwts print d7e22000 --show-allPull down the latest container image for RabbitMQ on Docker and run it, opening ports 5672 and 15672 to the container, which are used by default by AMQP, as shown in the following command:
docker run -it --rm --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:3.13.7-managementStart the RabbitMQ container, as shown in the following command:
docker run -it --rm --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:3.13.7-managementInstall the Library Manager CLI tool, as shown in the following command:
dotnet tool install -g Microsoft.Web.LibraryManager.CliAdd the signalr.js and signalr.min.js libraries to the project from the unpkg source, as shown in the following command:
libman install @microsoft/signalr@latest -p unpkg -d wwwroot/js/signalr --files dist/browser/signalr.js --files dist/browser/signalr.min.jsCreate a tools manifest file, as shown in the following command:
dotnet new tool-manifestInstall Strawberry Shake tools for the local project, as shown in the following command:
dotnet tool install StrawberryShake.Tools --localAdd a client for your GraphQL service, as shown in the following command:
dotnet graphql init https://localhost:5131/graphql/ -n NorthwindClientRun Northwind.Grpc.Service.exe and explicitly specify the URL with the port number to use, as shown in the following command:
Northwind.Grpc.Service.exe --urls "https://localhost:5141"