23

I have a VS solution that contains both .Net CORE and .Net standard projects. I have just changed all the .Net CORE projects to use .Net 5 by switching the Target Framework property as below enter image description here

But I can't do the same with the .Net standard projects because the Framework property dropdown doesn't have an option for .Net 5.

enter image description here

I did try the "Install other framework" option and installed the .Net 5 SDK (not sure why I need to do that as I already have .Net 5 on my system) but it didn't help - the dropdown still doesn't have .Net 5 afterwards.

What am I missing here?

Alexu
  • 1,015
  • 2
  • 12
  • 32
  • I'm guessing the available framework options are dependent upon the project type.This is controlled by the Project type guid in the csproj file. However upon reading, it's not recommended that you manually change this guid. What I'd probably do is create a new project of .net5 and move all of your files into it. – LarryBud Dec 10 '20 at 18:27
  • Thanks LarryBud. Yes, that would be my last resort as it's going to be a lot of work (I have many projects to convert). I wonder if there is any tools available that makes it simpler. – Alexu Dec 10 '20 at 19:17
  • What changes did you have to make? Maybe post an answer with details to help others. – LarryBud Dec 12 '20 at 14:47
  • 4
    open csproj in editor and change **TargetFramework** to **net5.0** – magicandre1981 Dec 13 '20 at 07:19

3 Answers3

16

I was able to convert all my .Net standard projects to .Net 5 mainly by modifying the project files. What I did was removing all the PropertyGroup sections in a project file and adding this

<PropertyGroup> 
   <TargetFramework>net5.0</TargetFramework> 
   <RootNamespace>MyNameSpace</RootNamespace> 
</PropertyGroup>

I was able to leave all the ItemGroup unchanged. Some of the project references didn't work initially but I was able to correct them by simply removing and adding them back again.

Alexu
  • 1,015
  • 2
  • 12
  • 32
10

Make sure to Unload project, Edit for the below PropertyGroup change and then Reload project

<PropertyGroup> 
   <TargetFramework>net5.0</TargetFramework> 
</PropertyGroup>
se7vanj
  • 160
  • 2
  • 8
-2

Visual Studio.Net 2022 lists .Net (core), .Net framework and .Net standard versions in the Target framework drop down list, so you can easily migrate from standard to another version.

enter image description here

Maybe, this has to do with this statement:

The motivation behind .NET Standard was to establish greater uniformity in the .NET ecosystem. .NET 5 and later versions adopt a different approach to establishing uniformity that eliminates the need for .NET Standard in most scenarios.

(see .NET Standard)

R. Schreurs
  • 8,587
  • 5
  • 43
  • 62
  • Doesn't seem to list them if the project is already .NET Standard however? At least that's what I am seeing in my VS. – vgru Apr 28 '22 at 09:51
  • 1
    @Groo I checked, but for a project currently targeting .Net Standard 2.1, .Net Core, .Net Framework and .Net Standard versions are shown. I am using VS.Net Professional Version 17.0.5. VS.Net 2019 Professional Version 16.11.12 only lists .Net Standard versions. – R. Schreurs Apr 28 '22 at 13:07
  • 1
    Ok thanks, well now that I checked, my VS 2022 pro is slightly newer at 17.1.5, but as I wrote, not sure if they really decided to remove it or something is not installed correctly on my side. But any case, not a big deal :) – vgru Apr 28 '22 at 15:17