DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 963,274 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
Stephany Henrique A
Stephany Henrique A

Posted on

.Net Comand Line Interface (CLI), create a project by terminal

.Net Command Line Interface (CLI) is a new tool essential for development in ASP.NET Core. What do I mean by β€œessential?” Simple, any person or tool that wants to develop in the new platform of Microsoft must use this tool. It is the first layer of development. The Visual Studio (VS) uses the .Net CLI to build, publish, run and other things. .Net CLI also is cross-platform, that is, it can run in Windows, Apple and Linux and to start with it you must download your distribuition to your SO.

You may wonder, β€œDo I need to learn this tool?” Those who work with VS do not need, because internally the VS use the .Net CLI. But when you do not use the VS, it will need to be used. Remember, now I can develop in other tools as Visual Studio Code, Sublime, Vim and others. Therefore, learning about it is good!

Which can make the person confused it is that some time ago the DNX tool was used, when .Net Core was beta. With the arrival of the ASP.NET Core in production, the DNX was replaced by DOTNET.

To use the .Net Command Line Interface (CLI) there is a pattern, driver (dotnet) + verb + argument (if there is). Below I explain the other commands:

  • β€œdotnet restore” restores all dependecies needed to project.
  • β€œdotnet build” compiles the application to validate if there are errors.
  • β€œdotnet run” runs the application.
  • β€œdotnet test” runs the tests of application.
  • β€œdotnet publish” publishes the application.
  • β€œdotnet pack” creates a Nuget Packages.

To execute a project created, we must execute the command β€œdotnet run”.

Let’s see a little working, I’m using Ubuntu 16.04. So, in the images below you can see I creating a web application and run it.

To create a web project, I used:

  • β€œnew” to create a new project.
  • β€œmvc” to create a MVC tempate.
  • β€œ-o” to give a project name.

After the project created, I access the project folder and can run the project because I created a project template.

And by last, this is the result.

By default these are all the commands included, but you can create your own commands, for this, access .NET Core CLI extensibility model.

Conclusion

.Net Command Line Interface (CLI) is a tool of the interface to develop in the .Net platform. Through it, we can create a new project, restore packages, running and others. With the .Net CLI, code editors can use it for development, because it is cross-platform. Developing in Windows, Linux or Apple already does not make difference in the new platform of Microsoft.

.NET Core Command Line Tools (CLI)

Did you like this article? Would you know more about .Net Core? I created a course at Udemy with a cheap price. Access https://www.udemy.com/aspnet-core-20-learn-concepts-and-creating-an-web-app

Top comments (0)

🌚 Browsing with dark mode makes you a better developer by a factor of exactly 40.

It's a scientific fact.