Header Ads Widget

Most usefull Dotnet CLI command

dotnet command and its use 

The .NET Core command-line interface (CLI) is a new cross-platform tool for creating, restoring packages, building, running and publishing .NET applications.

Visual Studio uses this CLI internally to restore, build, and publish your application. Other high-level IDEs, editors, and tools can use the CLI to support .NET Core applications.

All the command prefix or start with "dotnet". 

1. new - Creates a new project, configuration file, or solution based on the specified template


[-n] -- Project name

[-o] -- Output directiry

[-d] -- diagnostics

syntax -  dotnet new console -o MyProjectName

2. restore - to restore dependencies as well as project-specific tools that are specified in the project file.

   syntax - dotnet restore ./projects/MyProjectName/app1.csproj


3. Build -  builds the project

   syntax- dotnet build

4. Run - Runs source code without any explicit compile or launch commands.

   syntax - dotnet run


5. Publish - packages the application for deployment.

   syntax - dotnet publish -o path


6. add package - provides a convenient option to add or update a package reference in a project file.

   syntax - dotnet add  package <PACKAGE_NAME>

   example -dotnet add package Microsoft.EntityFrameworkCore

7. tool install- installs a .NET tool globally or local



dotnet tool install <PACKAGE_NAME> [--local]


dotnet tool install <PACKAGE_NAME> -g 

Post a Comment