Writing and compiling code using the .NET Core CLI tool

When you install Visual Studio 2017, or the .NET Core SDK, a Command Line Interface (CLI) tool named dotnet is installed as well as the .NET Core runtime.

dotnet has the following commands that all work on the project in the current folder:

  • dotnet new console: creates a new console application project
  • dotnet new classlib: creates a new assembly library project
  • dotnet new web: creates a new empty ASP.NET Core project
  • dotnet new mvc: creates a new ASP.NET Core MVC project
  • dotnet new webapi: creates a new ASP.NET Core Web API project
  • dotnet restore: downloads dependencies for the project
  • dotnet build: compiles the project
  • dotnet test: runs unit tests on the project
  • dotnet run: runs the project
  • dotnet ...

Get C# 7 and .NET Core: Modern Cross-Platform Development - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.