Home  Dotnet   Dotnet comm ...

dotnet commands

The dotnet command-line interface (CLI) is a powerful tool for managing .NET applications and projects. It allows you to perform various tasks such as creating projects, restoring dependencies, building applications, running tests, and more. Here's an overview of commonly used dotnet commands with examples:

1. Create a New Project

Use dotnet new to create a new .NET project.

dotnet new console -n MyConsoleApp

2. Restore Dependencies

Use dotnet restore to restore dependencies specified in the project file (*.csproj).

dotnet restore

3. Build the Project

Use dotnet build to build a .NET project.

dotnet build

4. Run the Project

Use dotnet run to build and run the project.

dotnet run

5. Add NuGet Packages

Use dotnet add package to add NuGet packages to the project.

dotnet add package Newtonsoft.Json

6. List Installed SDKs

Use dotnet --list-sdks to list installed .NET SDKs.

dotnet --list-sdks

7. List Installed Runtimes

Use dotnet --list-runtimes to list installed .NET runtimes.

dotnet --list-runtimes

8. Publish the Project

Use dotnet publish to publish the project for deployment.

dotnet publish -c Release -o ./publish

9. Clean the Project

Use dotnet clean to clean the build output of the project.

dotnet clean

10. Run Tests

Use dotnet test to run tests in the project.

dotnet test

11. Manage EF Core Migrations

Use dotnet ef to manage Entity Framework Core migrations.

dotnet ef migrations add InitialCreate
dotnet ef database update

12. Manage Global Tools

Use dotnet tool install to install global tools.

dotnet tool install -g dotnet-ef

13. Generate Documentation

Use dotnet doc to generate documentation for the project.

dotnet doc

14. Advanced Commands

Published on: Jun 24, 2024, 01:00 AM  
 

Comments

Add your comment