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
- Chapter 3 - Building Entity Models for SQL Server Using EF Core
- Chapter 8 - Building and Securing Web Services Using Minimal APIs
- Chapter 9 - Caching, Queuing, and Resilient Background Services
- Chapter 10 - Building Serverless Nanoservices Using Azure Functions
- Chapter 11 - Broadcasting Real-Time Communication Using SignalR
- Chapter 12 - Combining Data Sources Using GraphQL
- Chapter 13 - Building Efficient Microservices Using gRPC
- Chapter 14 - Building Web User Interfaces Using ASP.NET Core
- Chapter 15 - Building Web Components Using Blazor
- Chapter 16 - Building Mobile and Desktop Apps Using .NET MAUI
- Page 710 - Installing .NET MAUI workloads manually
code --list-extensions
code --install-extension ms-dotnettools.csdevkit
Listing all installed project templates:
dotnet new list
Installing a new project template:
dotnet new --install "Vue.Simple.Template"
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 check if you have already installed dotnet-ef
as a global tool:
dotnet tool list --global
To uninstall an existing global tool:
dotnet tool uninstall --global dotnet-ef
To install the latest version as a global tool:
dotnet tool install --global dotnet-ef
To install the latest preview version 9 as a global tool:
dotnet tool install --global dotnet-ef --version 9-*
Generate an entity model (from a local SQL Server):
dotnet ef dbcontext scaffold "Data Source=.;Initial Catalog=Northwind;Integrated Security=true;TrustServerCertificate=true;" Microsoft.EntityFrameworkCore.SqlServer --output-dir Models --namespace Northwind.Models --data-annotations --context NorthwindDb
Common 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;"
dotnet ef dbcontext scaffold "Data Source=.;Initial Catalog=Northwind;Integrated Security=true;TrustServerCertificate=True;" Microsoft.EntityFrameworkCore.SqlServer --namespace Northwind.EntityModels --data-annotations
dotnet test
Create a local JWT, as shown in the following command:
dotnet user-jwts create
Print all the information for the ID that was assigned, as shown in the following command:
dotnet user-jwts print d7e22000 --show-all
Pull 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.12-management
Start the RabbitMQ container, as shown in the following command:
docker run -it --rm --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:3.12-management
To install Azurite at the command prompt:
npm install -g azurite
Create a new Azure Functions project using C#, as shown in the following command:
func init --csharp
Create a new Azure Functions function using HTTP trigger that can be called anonymously, as shown in the following command:
func new --name NumbersToWordsFunction --template "HTTP trigger" --authlevel "anonymous"
Start the function locally, as shown in the following command:
func start
Install the Library Manager CLI tool, as shown in the following command:
dotnet tool install -g Microsoft.Web.LibraryManager.Cli
Add 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.js
Create a tools manifest file, as shown in the following command:
dotnet new tool-manifest
Install Strawberry Shake tools for the local project, as shown in the following command:
dotnet tool install StrawberryShake.Tools --local
Add a client for your GraphQL service, as shown in the following command:
dotnet graphql init https://localhost:5121/graphql/ -n NorthwindClient
Run 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:5131"
Run database migrations so that the database used to store credentials for authentication is created, as shown in the following command:
dotnet ef database update
Create a new project using the Blazor Web App project template:
dotnet new blazor --interactivity None -o Northwind.Blazor
To see which workloads are currently installed, enter the following command:
dotnet workload list
To see which workloads are available to install, enter the following command:
dotnet workload search
To install the .NET MAUI workloads for all platforms, enter the following command at the command line or terminal:
dotnet workload install maui
To update all existing workload installations, enter the following command:
dotnet workload update
To 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 clean
Create a .NET MAUI ContentPage (XAML) item using the CLI:
dotnet new maui-page-xaml --name SettingsPage.xaml
Create a .NET MAUI Resource Dictionary item using the CLI:
dotnet new maui-dict-xaml --name Northwind.xaml