dotnet command line interface (cli) cheat sheet

An alternative for using Visual Studio, developers can use the dotnet cli commands to execution any development task. Below are the most common commands that should be used. i will include the Microsoft document link if you need further information.

dotnet new

dotnet new <template name>

Use this command for creating new dotnet projects. The default project type is a CLI console, but you can specify the project type you need. These are list of some applicable template name

  • console
  • classlib
  • xunit
  • mstest

Example

dotnet new console -n ConsoleTemplateTest

The command above will create a new console app named ConsoleTemplateTest under the current directory.

Output

From this point, you can actually open your project quickly through Visual Studio code by using the command code . at the directory of your project

dotnet build

dotnet build

Build your .net application

Output

dotnet run

dotnet run

Run your application. Note that dotnet run also execute the dotnet build command.

Output

dotnet publish

dotnet publish

Compile and create a publish version of your application

Output