Visual Studio project templates without minimal API and top-level statement

Devs want the option to create new projects in Visual Studio without all of the minimalist stuff that was recently added (top-level statement, minimal API). At the very least, these features should be optional instead of being the default without a way to opt-out (to be fair, minimal API is optional).

What I typically do is create a project targeting .NET 5, and then switch it to .NET 6. That way I have the “old style” project layout, but targeting .NET 6. Best of both worlds.

Instead of doing this slightly tedious process every time, I decided to create a few non-minimalist project templates targeting .NET 6 (GitHub links to the template zip files):

I’ll show how to import a project template and use it. Furthermore, I’ll show how to easily create your own project template with Visual Studio.

Import a project template and use it

User-defined project templates come in a zip file. To import it, you just have to stick in the directory that Visual Studio looks in: %USERPROFILE%\Documents\<VS version>\Templates\ProjectTemplates\

Here’s a step-by-step example:

  1. Download the project template zip file you want (ex: Console App non-minimal .NET 6)
  2. Put it here: C:\Users\Mak\Documents\Visual Studio 2022\Templates\ProjectTemplates
  3. Restart Visual Studio
  4. Now create a new project, search for the template, and use it:
Visual Studio > Create a new project > Search for the imported template "nonminimal" > Double-click to use it

Note: Sometimes the search is really slow. Be patient and wait for your stuff to show up.

This creates a Console App targeting .NET 6 without the minimalist features.

Make your own project template

The simplest way to make your own template is to create a project from an existing template, tweak it how you want it, and then use the Export Template Wizard (Project > Export Template…) in Visual Studio.

In my case, I created a new project using the built-in Console App template targeting .NET 5. Then I tweaked the project by making it target .NET 6. Finally, I exported the project as a template with the following steps:

  • In the Visual Studio menu, click Project > Export Template…
Visual Studio menu > Projects > Export Template...
  • Select the Project Template as the template type. Select the project to templatize. Click Next.
Export Template Wizard: Project template selected. Project dropdown is showing the name of the project "ConsoleApp"

Note: If you have multiple projects in the solution, be sure to select the right project from the dropdown. Otherwise you’ll end up creating a template from the wrong project.

  • Fill in the template name and description. Click Finish when you’re done.
Export Template Wizard: Fill in the name and description. Leave the checkbox defaults. It'll automatically import the template and show you the template zip

This will export the template as a zip file, and also import it automatically so you can use it right away. If you want to use it on a different machine, see the Import a template and use it section above.

Make sure to use meaningful and descriptive names for the template name and description.

Leave a Comment