nicomp
nicomp

Reputation: 4647

How can .Net 6.0 console app template create the old program style

Using .Net 6.0, when we create a C# project with the Console app template we get only this:

// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");

There is a way to get back to the old program style, it requires a different framework: https://learn.microsoft.com/en-us/dotnet/core/tutorials/top-level-templates#use-the-old-program-style. Well, guess what? I can't change the framework.

Is there an easier way to get the old template back while still using .Net 6.0?

Editorial: please go here and vote against this (stupid) new template: https://github.com/dotnet/docs/issues/27420

Upvotes: 1

Views: 1440

Answers (2)

Valeriy
Valeriy

Reputation: 11

Use the old program style.

Starting with .NET SDK 6.0.300, the console template has a --use-program-main option. Use it to create a console project that doesn't use top-level statements and has a Main method.

https://learn.microsoft.com/en-us/dotnet/core/tutorials/top-level-templates#use-the-old-program-style

Upvotes: 1

Pieterjan
Pieterjan

Reputation: 3531

You should see a checkbox on the third step (1 = Create a new project / 2 = Configure your new project / 3 = Additional information).

Create console application - additional information

You might try and update the dotnet templates using

dotnet new --update-check
dotnet new --update-apply

Upvotes: 1

Related Questions