DevOps – Create an ASP.NET Core Application using the .NET CLI

In this blog post, I will show you how to create an ASP.NET Core MVC application using the .NET Core CLI tools.

The .NET Core CLI tools are powerful tools that allow us to create, build and deploy a .NET applications without using an IDE like VS Code and Visual Studio 2019.

Installation

The CLI tools are installed by default when you install .NET Core on your machines.

So from that prospective, there is nothing we need to do to get the tools.

Every time you update your .NET Core version the CLI tools will also get updated.

To use the CLI tools we type:

Dotnet

To create a .NET application we use the new switch (shown below) and we can also use the help.

The help switch will list all the available templates we can use.

dotnet new --help

A new template that has been released with .NET Core is that Worker Service template which I will talk about in the next few articles.

Create an ASP.NET Core MVC application

In my example, I will create an ASP.NET Core MVC application using the line below.

dotnet new MVC --name cliapp

Once the application has been created I can build it using the line below:

dotnet build cliapp

Run the application

To run the application, I will browse to the application’s folder using the cd command.

Cd cliapp

To run it, I will use the run command.

Dotnet run cliapp

In the command output, you will see the URL that will allow you access to the application,

Below, you can see my ASP.NET Core MVC application.

To publish the app I can use:

Dotnet publish cliapp

For all commands and option run the following command

Dotnet --help

Processing…
Success! You're on the list.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.