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-extensionscode --install-extension ms-dotnettools.csdevkitListing all installed project templates:
dotnet new listInstalling a new project template:
dotnet new --install "Vue.Simple.Template"Getting help for a dotnet command like build in a web browser:
dotnet help buildGetting 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 --globalTo uninstall an existing global tool:
dotnet tool uninstall --global dotnet-efTo install the latest version as a global tool:
dotnet tool install --global dotnet-efTo 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 NorthwindDbCommon 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-annotationsdotnet testCreate 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.12-managementStart the RabbitMQ container, as shown in the following command:
docker run -it --rm --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:3.12-managementTo install Azurite at the command prompt:
npm install -g azuriteCreate a new Azure Functions project using C#, as shown in the following command:
func init --csharpCreate 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 startInstall 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:5121/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: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 updateCreate a new project using the Blazor Web App project template:
dotnet new blazor --interactivity None -o Northwind.BlazorTo see which workloads are currently installed, enter the following command:
dotnet workload listTo see which workloads are available to install, enter the following command:
dotnet workload searchTo 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 cleanCreate a .NET MAUI ContentPage (XAML) item using the CLI:
dotnet new maui-page-xaml --name SettingsPage.xamlCreate a .NET MAUI Resource Dictionary item using the CLI:
dotnet new maui-dict-xaml --name Northwind.xaml