Dot net command at a glance

less than 1 minute read

  • Verify the dotnet version
dotnet --version
  • You can see all the SDKs and runtimes installed by entering
dotnet --info
  • To see a list of project templates currently available
dotnet new --list
  • Create a console application hame helloworld
mkdir helloworld
cd helloworld
dotnet new console

or

dotnet new console --name myhelloworld
  • Create a web application hame myhelloweb
mkdir helloweb
cd helloweb
dotnet new mvc --name myhelloweb
  • To restore dot net dependencies
dotnet restore
  • To build dot net application
dotnet build
  • Run the application, go to the project directory
dotnet run
  • To publish the application, go to the project directory
dotnet publish
  • To install dotnet package
Syntax:
$ dotnet add package <PackageName> 
Example:
$ dotnet add package MailKit 
  • Create a new webapi project
dotnet new webapi --name mywebapi
dotnet run
  • Create dotnet Razor Page Project
dotnet new razor
  • Create Razor Page. Go into the Pages folder and create anew folder name Employees and enter the following command
dotnet new page -n Index

Comments