The .NET Core Command Line Interface (CLI) is a tool used for developing and building .NET applications.Youc an perform different actions using the CLI such as creating a new project , restoring dependencies,building project,publishing project.
To use dotnet core CLI you need to install SDK from the following url:
After installing the SDK you can execute dotnet core commands using the CLI commands.
CLI commands uses the common pattern as:
dotnet CommandName Arguments
There are different commands for different actions such as:
new :used to create a new project.You can create different types of projects such as:
Application type :Console application
For creating console application.
To create a new console application use the following command:
dotnet new console
after you execute the above command you will get the following message:
There are different types of applications you can create using the new command.
Application type:Class library
For creating class library.
to create a new class library application use the following command:
dotnet new classlib
Application type:Unit test project
This is for creating unit test project.
dotnet new console
Application type:ASP.NET Core Web App(Model-View-Controller)
dotnet new mvc
restore: restores the nuget projects for the project.
dotnet restore is run implicitly when you execute new command
dotnet restore "path of the project"
The NuGet.config to be used for restore operation.
To Disable restoring of multiple projects in parallel.
To forces all dependencies to be resolved irrespective of the last restore.
build:builds the project
This command builds a project along with its dependencies into Intermediate Language Code (IL) files having dll or exe extension.Other files produced using this command are:
- .pdb contains debugging information
- JSON file (*.deps.json) consists of the dependencies of the application
- .runtimeconfig.json consists of run time information
Some of the arguments of the build command are:
- no-restore to disable automatic restore of dependencies (in .NET Core 2.0)
project.assets.json file if there are any dependencies they are listed in this file.This file is created by the restore command.The restore command is automatically executed when the build command is executed in .NET Core 2.0.
publish: for publishing
creates a folder consisting of the application and its dependencies.This folder is used for publishing.
Some of the arguments of the publish command are:
run: running application from the source code
Output is written to the default location bin/<configuration>/<target>
- project <PATH>