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

瘦欲@ 提交于 2021-01-21 12:50:14

问题


I can not see the Class Library(.NET) option on Add a New Project window in Visual Studio 16.8.1. How can I create a Class Library (.NET) project? (Not .Net Core or .Net Framework)


回答1:


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.




回答2:


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

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

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




回答3:


The easiest way is to create .NET Core library and then simply change Target framework in project properties. .NET 5.0 is available!

But note, if you create .NET Framework library, the options to change to .NET Core or .NET 5.0 will not be there.

It seems like Visual Studio is treating .NET 5.0 as the latest version of .NET Core. It's in the same bin.

This is with Visual Studio 2019 version 16.8.4



来源:https://stackoverflow.com/questions/64874414/how-to-create-net-5-0-class-library-project-in-visual-studio-2019-16-8-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!