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

rickab10

Stephany Henrique A

Posted on September 13, 2017

.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

💖 💪 🙅 🚩
rickab10
Stephany Henrique A

Posted on September 13, 2017

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related