.Net Comand Line Interface (CLI), create a project by terminal
Tags: netcore, dotnetcli
Published: 2017-09-13 21:41:50

---
title: .Net Comand Line Interface (CLI), create a project by terminal
published: true
description: .Net Command Line Interface (CLI)Â is a new tool essential for development in ASP.NET Core. What do I mean by "essential?" I respond here
tags: .Net Core, dotnet cli
---
.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:

<ul>
    <li>“dotnet restore” restores all dependecies needed to project.</li>
    <li>“dotnet build” compiles the application to validate if there are errors.</li>
    <li>“dotnet run” runs the application.</li>
    <li>“dotnet test” runs the tests of application.</li>
    <li>“dotnet publish” publishes the application.</li>
    <li>“dotnet pack” creates a Nuget Packages.</li>
</ul>

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.

<img src="http://www.stephanybatista.com/wp-content/uploads/2016/06/Selection_004-1024x608.png"/>

To create a web project, I used:

<ul>
    <li>“new” to create a new project.</li>
    <li>“mvc” to create a MVC tempate.</li>
    <li>“-o” to give a project name.</li>
</ul>

<img src="http://www.stephanybatista.com/wp-content/uploads/2016/06/Selection_006-1024x604.png"/>

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

<img src="http://www.stephanybatista.com/wp-content/uploads/2016/06/Home-Page-UsingDotNetCLI-Google-Chrome_009-1024x580.png"/>

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 <a href="https://dotnet.github.io/docs/core-concepts/core-sdk/cli/extensibility.html">.NET Core CLI extensibility model.<a/>

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.

<a href="http://dotnet.github.io/docs/core-concepts/core-sdk/cli/overview.html">.NET Core Command Line Tools (CLI)</a>

<b>Did you like this article?</b> 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