Alexu
Alexu

Reputation: 1195

How to migrate a .Net standard project to .Net 5 in VS.net solution?

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?

Upvotes: 23

Views: 7506

Answers (3)

R. Schreurs
R. Schreurs

Reputation: 9065

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)

Upvotes: -2

se7vanj
se7vanj

Reputation: 160

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

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

Upvotes: 10

Alexu
Alexu

Reputation: 1195

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.

Upvotes: 16

Related Questions