I am using dotnet cli to create an ASP.NET Core Web API
dotnet new webapi --output WebAPI;
Is it possible to create it but without top-level statements?
You can use --use-program-main
switch (or --use-program-main true
) for the dotnet new
command:
dotnet new webapi --output WebAPI --use-program-main
Note that this will just generate Main
method. The minimal hosting model will still be used (so no Startup
).