How to create .Net 5.0 Class Library project in Visual Studio 2019 16.8.1?

In Visual Studio 2019, I believe it needs to be 16.8+, you can enable the preview feature Show all .NET Core templates in the New project dialog.

enter image description here

Go Tools -> Options -> Environment -> Preview Features -> Show all .NET Core templates in the New project dialog (Requires Restart)

Then close Visual Studio and reopen it. Now from the new project dialog there should be a Class Library with a C# in the tags.

enter image description here

From here, click Next. Fill out where you want it to be made and what to call it as you normally would.

enter image description here

Then click Next again. This will bring you to a new screen that has a drop down for the Target Framework.

enter image description here

Set this to .NET 5.0 and click Create. This creates a .NET 5.0 class library and opens it in the IDE.


If the project templates are still giving you .NET Core 3.1 as the highest option, and the project properties options aren't allowing what you want - it isn't a problem: simply right-click on the project in Solution Explorer and select "Edit Project File", to edit the .csproj, and you can change the target framework - for example, from

<TargetFramework>netcoreapp3.1</TargetFramework>

to

<TargetFramework>net5.0</TargetFramework>

to target .NET 5, or

<TargetFrameworks>netcoreapp3.1;net5.0</TargetFrameworks>

to multi-target.


You can try the following steps to create a Class Library project based on .NET 5.0.

First, please download the .NET 5.0 SDK from Download .NET 5.0 and install it.

Second, please use the following command to create the project.

dotnet new Classlib -n Testlib

enter image description here

Third, please find the specific path and open the project Testlib.csproj.

Finally, you can see a class library based on .NET 5.0.

enter image description here