In this article, we will explain the processes such as installing, running and publishing packages with the Asp.Net Core CLI command line. You can compare the “.Net Core CLI” command-line interface to Cisco, Huawei CLI environments used when configuring network devices. The CLI environment is not actually a tool that does complex tasks such as installing, running, publishing packages, in short, managing the operations to be done on the cross-platform.
Since “.Net Core CLI” is installed with “.Net Core SDK” in new version Visual Studio versions, there is no need for a separate installation. In order to test whether the “.Net Core SDK” installation is on our computers and whether it works properly, you can type “dotnet” in the command line of the Windows operating system and examine the explanations. The command structure for the operations to be performed on the CLI is as follows.
dotnet <command> <arguments> <options>
As can be seen in the command line scripts above, all commands start with the dotnet statement. The action to be taken after the dotnet login should be given with the command. This command can be called the action itself. Arguments and, if any, options must be specified after the command.
You can review the CLI basic CLI commands for Microsoft .Net Core 2.x versions from the table below.
.Net CORE CLI Basic Commands
|Creates a new project or solution file.
|dotnet new “my first console app”
|Restores the project’s tools.
|It performs the build process.
|It is used to run the source code.
|It is the packaging process to bring the project to a published state.
|Performs unit testing.
|It performs the test process on the specified files.
|dotnet vtest testprojem.dll
|Packages the code into the NuGet environment.
|Clears the output of the project.
|Replaces the .Net Core solution file.
|dotnet sln todo.sln add todo-app/todo-app.csproj
|Used to get help about commands.
|dotnet help new
|Stores the specified assemblies in the runtime package store.
|dotnet store –manifest packages.csproj –framework-version 2.0.0
.Net CORE CLI Modification Commands
|Project Change Commands
|It is used to add a package reference to the project file.
|dotnet add package Newtonsoft.Json
|Used to add references to the project.
|dotnet add app/app.csproj reference lib/lib.csproj
|Used to remove the NuGet package from the project.
|dotnet remove package Newtonsoft.Json
|Used to remove project references from the project.
|dotnet remove app/app.csproj reference lib/lib.csproj
|Used to list project references.
|dotnet list app/app.csproj reference
.Net CORE CLI Advanced Commands
|It allows the package to be deleted from the server or removed from the list.
|dotnet nuget delete Microsoft.AspNetCore.Mvc
|http-request cache is used to list or clear local NuGet resources in temporary cache or global packages.
|dotnet nuget locals all -ldotnet nuget locals http-cache –list
|It allows the packet to be transmitted to the server and broadcast.
|dotnet nuget locals http-cache –list
|Used to allow MSBuild access.
|dotnet install script
|This is the command used to install the .Net Core CLI tools.
|./dotnet-install.ps1 -Channel LTS
The example uses shown in the tables are all for the Windows platform. When you click on the commands, you can access detailed information. You can also see the Windows and macOS/Linux equivalents of a command. In order to get help about commands, we need to type -h or -help to the right of the command we want to get help from, as stated in the table above. For example, to get help about the “restore” command, it will be enough to type “dotnet restore -h” as we can see from the picture below.