How to create new dotnetcore EMPTY web project template from a command line
Asked Answered
T

3

9

At the command line I can type

dotnet new -t web

to scaffold a new asp.net core web project but it contains the 'full template' (equivalent to creating a new MVC project in Visual Studio).

In visual studio I can create a new EMPTY project too (which just returns a 'Hello World' string response).

Is there an equivalent command line option to scaffold an EMPTY project?

I have found the docs for the dotnet newcommand here but there doesn't seem to be such an option

Tilla answered 14/1, 2017 at 11:17 Comment(2)
Check this issue on github github.com/dotnet/cli/issues/3934 they however suggest using yo for the empty projectTolidine
Yo was also suggested by S Hanselman here as well Exploring dotnet new with .NET Core. The tooling just hasn't reached that level as yet. But at least there are some workarounds available.Tolidine
T
3

Update

Microsoft no longer support yeoman, and the provided links below will redirect permanently to:

dotnet new


Outdated Answer

According to MS docs

Building Projects with Yeoman

you can also use the Yeoman command-line tool yo alongside a Yeoman generator.

You are going to need to install Node.js and npm.

From there run the ASP.NET generator for yo

yo aspnet

The generator displays a menu. Arrow down to the Empty Web Application project, tap Enter and then name your project. Yeoman will scaffold the project and its supporting files.

Tolidine answered 14/1, 2017 at 12:13 Comment(0)
L
19

answer

dotnet new web

How i figured it out

(can also use 2 validate in future if cli changes)

.netcore cli/shell has a utility to list all of the new templates/projects that can be created with "new". Using that you can find the empty web app create command

dotnet new -l 

which then returned this

Templates                                     Short Name           Language    Tags                  
--------------------------------------------  -------------------  ----------  ----------------------
Console Application                           console              [C#],F#,VB  Common/Console        
Class library                                 classlib             [C#],F#,VB  Common/Library        
WPF Application                               wpf                  [C#],VB     Common/WPF            
WPF Class library                             wpflib               [C#],VB     Common/WPF            
WPF Custom Control Library                    wpfcustomcontrollib  [C#],VB     Common/WPF            
WPF User Control Library                      wpfusercontrollib    [C#],VB     Common/WPF            
Windows Forms App                             winforms             [C#],VB     Common/WinForms       
Windows Forms Control Library                 winformscontrollib   [C#],VB     Common/WinForms       
Windows Forms Class Library                   winformslib          [C#],VB     Common/WinForms       
Worker Service                                worker               [C#],F#     Common/Worker/Web     
Unit Test Project                             mstest               [C#],F#,VB  Test/MSTest           
NUnit 3 Test Project                          nunit                [C#],F#,VB  Test/NUnit            
NUnit 3 Test Item                             nunit-test           [C#],F#,VB  Test/NUnit            
xUnit Test Project                            xunit                [C#],F#,VB  Test/xUnit            
Razor Component                               razorcomponent       [C#]        Web/ASP.NET           
Razor Page                                    page                 [C#]        Web/ASP.NET           
MVC ViewImports                               viewimports          [C#]        Web/ASP.NET           
MVC ViewStart                                 viewstart            [C#]        Web/ASP.NET           
Blazor Server App                             blazorserver         [C#]        Web/Blazor            
Blazor WebAssembly App                        blazorwasm           [C#]        Web/Blazor/WebAssembly
ASP.NET Core Empty                            web                  [C#],F#     Web/Empty             
ASP.NET Core Web App (Model-View-Controller)  mvc                  [C#],F#     Web/MVC               
ASP.NET Core Web App                          webapp               [C#]        Web/MVC/Razor Pages   
ASP.NET Core with Angular                     angular              [C#]        Web/MVC/SPA           
ASP.NET Core with React.js                    react                [C#]        Web/MVC/SPA           
ASP.NET Core with React.js and Redux          reactredux           [C#]        Web/MVC/SPA           
Razor Class Library                           razorclasslib        [C#]        Web/Razor/Library     
ASP.NET Core Web API                          webapi               [C#],F#     Web/WebAPI            
ASP.NET Core gRPC Service                     grpc                 [C#]        Web/gRPC              
dotnet gitignore file                         gitignore                        Config                
global.json file                              globaljson                       Config                
NuGet Config                                  nugetconfig                      Config                
Dotnet local tool manifest file               tool-manifest                    Config                
Web Config                                    webconfig                        Config                
Solution File                                 sln                              Solution              
Protocol Buffer File                          proto                            Web/gRPC              
Leboff answered 22/3, 2021 at 13:26 Comment(1)
This should be the accepted answer.Duel
T
3

Update

Microsoft no longer support yeoman, and the provided links below will redirect permanently to:

dotnet new


Outdated Answer

According to MS docs

Building Projects with Yeoman

you can also use the Yeoman command-line tool yo alongside a Yeoman generator.

You are going to need to install Node.js and npm.

From there run the ASP.NET generator for yo

yo aspnet

The generator displays a menu. Arrow down to the Empty Web Application project, tap Enter and then name your project. Yeoman will scaffold the project and its supporting files.

Tolidine answered 14/1, 2017 at 12:13 Comment(0)
A
0

According to: https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-new?tabs=netcore21

dotnet new mvc -au None
Afterpiece answered 9/9, 2018 at 0:13 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.