Create a new .NET MVC project starter (with the CLI)

DotNet starter project MVC generation using the command line interface.

.NET Core is a hugely popular web framework from Microsoft. You can use it to develop applications in F# and CSharp (or any CLR language) with built in support for many common operations. In this post we will show you how to scaffold a new .NET Core application using the CLI tools.

Install dotnet CLI

To begin with make sure you have the .NET SDK and dotnet cli installed.

Create a new project

Open a terminal and navigate to your project folder. Run the help command for dotnet new --list to see possible options

dotnet new --list
These templates matched your input:

    Template Name                                 Short Name      Language    Tags
--------------------------------------------  --------------  ----------  --------------------------
    ASP.NET Core Empty                            web             [C#],F#     Web/Empty
ASP.NET Core gRPC Service                     grpc            [C#]        Web/gRPC
ASP.NET Core Web API                          webapi          [C#],F#     Web/WebAPI
ASP.NET Core Web App                          webapp,razor    [C#]        Web/MVC/Razor Pages
ASP.NET Core Web App (Model-View-Controller)  mvc             [C#],F#     Web/MVC            

Choose a template type

We will create a new webapp which support HTML view rendering and MVC controllers.

 dotnet new webapp -o my-project
The template "ASP.NET Core Web App" was created successfully.
This template contains technologies from parties other than Microsoft, see https://aka.ms/aspnetcore/6.0-third-party-notices for details.

Processing post-creation actions...
Running 'dotnet restore' on /root/my-project/my-project.csproj...
  Determining projects to restore...
  Restored /root/my-project/my-project.csproj (in 60 ms).
Restore succeeded.

Creating tests using the CLI

We can create test packages for xUnit, MSTest and NUnit using the command line:

 dotnet new xunit -o test --name test
The template "xUnit Test Project" was created successfully.

Processing post-creation actions...
Running 'dotnet restore' on /root/ms2-sms-ingest/test/test.csproj...
  Determining projects to restore...
  Restored /root/ms2-sms-ingest/test/test.csproj (in 298 ms).
Restore succeeded.