Classic.Console.Templates 0.2.1

dotnet new install Classic.Console.Templates::0.2.1                
This package contains a .NET Template Package you can call from the shell/command line.

classic-dotnet-templates

Provides .NET 6+ project templates that do not use top-level statements.

Installing this package using dotnet will make the templates available in both Visual Studio 2022 and the dotnet new CLI command.

Install from NuGet

dotnet new -i Classic.Console.Templates

What Is This?

Beginning with .NET 6, project templates for Console applications use new features called "global usings" and "top-level statements".

This means a new Console project's Program.cs looks like this:

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

Instead of the "classic" Program.cs which looks like this:

using System;

namespace MyProject
{
    internal class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello, World!");
        }
    }
}

There is currently no option to use the "classic" template if you wish. Installing this template pack will add a "classic" template to VS2022:

VS2022 Screenshot

Using this template will allow you to select which template features to use:

VS2022 Screenshot

Use from CLI

To create a new project from the command line:

dotnet new console-classic

Template features can be toggled:

dotnet new console-classic --topLevelProgram=false --nrt=true --implicitUsings=false

Available options:

--nrt: If true, turns on nullable reference types. [defaults to 'true']
--topLevelProgram: If true, auto-generates the top level statements, skipping explicit main methods, class and namespace. [defaults to 'false']
--implicitUsings: If true, auto-imports many common using statements. [defaults to 'false']

Uninstall

This template pack can be uninstalled with:

dotnet new -u Classic.Console.Templates

  • net6.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.2.1 1,549 10/10/2021
0.2.0 488 10/10/2021
0.1.0 319 10/7/2021