1

I can create .NET Framework and .NET Core but there is no option to create .NET library which is supposed to be the new .NET 5.0

I have seen the I can't create console application with .NET 5.0 as well (option missing) but I can create WPF application with that.

I want to create .NET library so to be able to use with WPF project and ASP project created with .NET 5.0 as well, so why is that option not there? I don't need it terribly in console but it would be nice to so I can test/access the library there as well.

My visual studio is up to date with everything.

zar
  • 11,361
  • 14
  • 96
  • 178
  • 1
    Does this answer your question? [How to create .Net 5.0 Class Library project in Visual Studio 2019 16.8.1?](https://stackoverflow.com/questions/64874414/how-to-create-net-5-0-class-library-project-in-visual-studio-2019-16-8-1) and [.NET 5 not available in Visual Studio 2019](https://stackoverflow.com/questions/60843091/net-5-not-available-in-visual-studio-2019) –  Jan 16 '21 at 10:57
  • Are you sure that you have upgraded to the latest Visual Studio version? I updated to Visual Studio 16.10.2 and can now create class libraries of .NET 5 directly. https://developercommunity.visualstudio.com/t/target-frameworks-missing/1208780 – thesystem Jun 23 '21 at 21:42

3 Answers3

1

First, we need to check your .net version please check your dotnet SDKs by command below (in git bash or Windows cmd)

dotnet --info

for example, this is my dotnet SDKs enter image description here

If you had no problems with SDKs check your Visual Studio for support .net5

whatever you can change the Target Framework version OR the c# Lang Version manually in .csproj file

  <PropertyGroup>
    <TargetFramework>net5.0</TargetFramework>
    <LangVersion>9.0</LangVersion>
  </PropertyGroup>

OR

  <PropertyGroup>
    <TargetFramework>net5.0</TargetFramework>
    <LangVersion>latest</LangVersion>
  </PropertyGroup>

enter image description here

Nima Airyana
  • 146
  • 5
  • This didn't work. After these changes (both versions), VS doesn't load the project. – zar Jan 17 '21 at 06:14
  • for checking the project, please open the project with vscode and run it, if everything is ok with vscode, We can see that the project is not a problem and is the only problem in Visual Studio – Nima Airyana Jan 17 '21 at 07:09
0

For the sake of completion. I found a better way how to accomplish that and I answered the linked question with my solution here.

Essentially you just create .NET Core library and then change the version to .NET 5. See complete answer with screenshot in the linked proved above.

zar
  • 11,361
  • 14
  • 96
  • 178
  • The logic behind is also simple, that .NET 5 is an upgrade of .NET Core 3.1. Microsoft dropped "Core" for simplity. – Lex Li Jan 17 '21 at 06:46
  • @LexLi Yes, I noted that in my detailed answer in the other question linked. – zar Jan 17 '21 at 07:10
-1

Step 1

Open Visual Studio Installer and make sure following are installed:

  1. ASP.NET and Web Development
  2. .NET desktop development
  3. .NET Core cross-platform development

Step 2

Open Visual Studio 2019

  1. Go to File Menu --> New --> Project
  2. In Create New Project Window make sure all the filters are clear in the right pane
  3. In Create New Project Window enter "library" in the "Search for templates" box at the top and hit enter to display library project type templates below

enter image description here

Step 3

After creating class Library Project follow instructions in following post to change type of class library project to target .NET 5.0 How to create .Net 5.0 Class Library project in Visual Studio 2019 16.8.1?

NCCSBIM071
  • 1,207
  • 1
  • 16
  • 30
  • Thank you for taking the time to share your knowledge & experience. But your answer has a low quality. Sometimes a comment or a flag/close may be more relevant. To help you improve your answersplease read [How do I write a good answer](https://stackoverflow.com/help/how-to-answer), [How do I write a good answer to a question](https://meta.stackexchange.com/questions/7656/how-do-i-write-a-good-answer-to-a-question) & [Answering technical questions helpfully](https://codeblog.jonskeet.uk/2009/02/17/answering-technical-questions-helpfully). –  Jan 16 '21 at 10:58
  • @OlivierRogier, On what basis are you saying my answer is of lower quality? I have explained each step thoroughly. I have added both a comment and detail steps just in case asker has difficulty following either of them. You are saying answer is of lower quality when it is you who have redundantly added a comment with the same link that I have already commented. – NCCSBIM071 Jan 16 '21 at 11:12
  • @OlivierRogier, What if asker has missed to clear filters in "Create New Project" dialog that will never show library project templates? Of course there are tons of tutorials but they will not solve his problem, if it had solved asker would have already followed that and not post here. My response is clear and thorough and I believe it is you who is being overly precise thereby giving short answers which may be difficult for asker to follow. – NCCSBIM071 Jan 16 '21 at 11:23