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:
https://www.microsoft.com/net/download/windows
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.
argument :console
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.
argument name:classlib
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.
argument name:mstest
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"
arguments:
configfile
The NuGet.config to be used for restore operation.
--configfile "file"
disable-parallel
To Disable restoring of multiple projects in parallel.
force
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:
- PROJECT
- configuration
- framework
- no-dependencies
- 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:
- configuration
- framework
- force
- no-dependencies
- no-restore
- output
run: running application from the source code
Output is written to the default location bin/<configuration>/<target>
arguments:
- configuration
- framework
- help
- -no-build
- no-dependencies
- -no-restore
- project <PATH>
Leave a Reply