Codementor Events

Popular commands in .NET CLI

Published Jan 17, 2021
Popular commands in .NET CLI

.Net CLI is command line interface for building, developing, running and publishing .Net applications.

There are some Popular command that i will discuss about them in this Blog.
Let first start with Basic one's.

Basic CLI Commands:

dotnet new

This command used to make new project and solution in .net framework and .net core. By using this command you can make any project without interacting with UI of the developing tool such as, Visual studio, VS code etc.

dotnet restore

This command help us to restore the nuget packages that we have added in our project or solutions.
This command is very helpful while working with .net core projects,
Because when you are using GIT as a version control tools, then your developing team not store the packages file in GIT because that will take a lot of space, therefore most of the developer use this command to install the packages in their local machines. instead of pushing and getting it from git.
The packages file contains all the packages that will reinstall into your machine after running this command.
Remember
You don't need to run this commmand because it implicitly executed by the all commands like, dotnet new, dotnet build, dotnet test, dotnet publish, etc.

dotnet build

This command help us to build the entire solution and project without interacting with User interface, also this is very helpful while developing application,
Many developer use this command in Package Manager console also.
Remember:
This command depends on the dotnet restore command to restore all the nuget packes first for the solution.

dotnet run

The dotnet run command provides a very convenient way to run the application from the source code in one command.
Remenber:
This command depends on the dotnet build command to build the code first.
as requirements for the build command , project must be restore first, its mean all the packages must be installed before executing this command otherwise it will execure the .net build command to install those packages first.
If you run the dotnet run command the dotnet build command must be executed first every time when you execure the run command.

dotnet publish

This command is just use when we do deployement on any server or file system.
This command generate the some dll and published folders for make it running on server machine,

Remember
This command will never generate the New making folders by the developer like Uploading files inside the project., (Virtual Directory concept).
You must have to copy paste those folder into your server directory.
OR make it new ones with the same name if you don't want to copy anyfiles from this local folder.


I hope this necessary information helpfull for you to start learning with .Net CLI.
If you face any problem while interacting with .Net CLI you can leave a comment below, I will answer your quries.


Please like and share.
Thank you !

Discover and read more posts from Rizwan
get started
post commentsBe the first to share your opinion
Show more replies