Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 995
Alexu Avatar asked Dec 10 '20 18:12

Alexu


People also ask

Does Vscode support .NET 5?

The C# extension for Visual Studio Code already supports . NET 5.0 and C# 9. . NET 5.0 is the first release in our .


2 Answers

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.

like image 168
Alexu Avatar answered Oct 22 '22 16:10

Alexu


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

<PropertyGroup> 
   <TargetFramework>net5.0</TargetFramework> 
</PropertyGroup>
like image 44
se7vanj Avatar answered Oct 22 '22 16:10

se7vanj