'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
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.
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?
Solution 1:[1]
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.
Solution 2:[2]
Make sure to Unload project, Edit for the below PropertyGroup change and then Reload project
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
Solution 3:[3]
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.
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)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Alexu |
Solution 2 | se7vanj |
Solution 3 |