Unfortunately, Visual Studio 2019 (even the latest preview) doesn't default to .NET 5.
But you can create your own Project template that targets .NET 5. Please follow this documentation to achieve that: Tutorial: Create a project template
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I have Visual Studio 2019 Community, version 16.8.3. How do I use it to create a .NET 5.0 Console application without editing the project file? If I choose the Console .NET Core template, it creates a project file targeted for .NET Core 3.1 (netcoreapp3.1). To use .NET 5.0 and C# 9 features, I have to edit that project file to read "net5.0" (and LanguageVersion 9.0). I was hoping with the release of .NET 5.0 that there would be new templates in Visual Studio to directly create .NET 5.0 projects (and not just Console, but also Windows, UWP, WPF, etc.)
Unfortunately, Visual Studio 2019 (even the latest preview) doesn't default to .NET 5.
But you can create your own Project template that targets .NET 5. Please follow this documentation to achieve that: Tutorial: Create a project template
You can enable all .NET Core and .NET 5.0 templates:
Tools > Options > Preview Features > “Show all .NET Core templates in the New project dialog (requires restart)”
Instead of editing the project file manually, try creating a new .NET Core project, go to Project Properties and change the Target framework to “.NET 5.0”.
Either way, it's a change to the project file after creating one from the template. Is there a way to create a new template file that shows up in the list of templates when you start Visual Studio that automatically sets up the project file for .NET 5.0 when a new project is created?
Hello @Nicholas Piazza
See the following project for a sample console app using .NET 5, C# 9.
For you project, double click on the project to open it up and replace the contents with the following. Now to make it easy for other project, select all text in the .csproj file, drag it to the toolbox. Now when needed in another project delete that project's .csproj file contents and drag in the code from the toolbox. If you right click on that item you can rename it e.g.
This is the project file contents
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<LangVersion>9.0</LangVersion>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
</Project>
For Windows Forms
<PropertyGroup>
<OutputType>WinExe</OutputType>
<LangVersion>9.0</LangVersion>
<TargetFramework>net5.0-windows</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>