14

I tried upgrading a .NET standard project to a .NET 6 project using this upgrade assistant tool:

https://dotnet.microsoft.com/en-us/platform/upgrade-assistant/tutorial/install-upgrade-assistant

I ran the tool as the steps describe (installing it, using upgrade-assistant analyze with the project csproj path and then upgrade-assistant upgrade with the path), but after it was done, the project still remains with a target framework of .net standard 2.0.

Is there something else needs to be done in order to upgrade the framework?

CodeMonkey
  • 11,196
  • 30
  • 112
  • 203
  • 3
    You don't need that tool at all. .NET 6 is .NET *Core* 6 and can already use .NET Standard libraries. If you want to upgrade the version of your project, just change the `TargetFramework` to `nestandard2.1` or `net6.0`. You'll probably need to upgrade any old packages – Panagiotis Kanavos Jul 06 '22 at 11:47
  • Why did you try using that tool in the first place? Did you encounter a problem using your library in a .NET 6 project? – Panagiotis Kanavos Jul 06 '22 at 11:48
  • 1
    @PanagiotisKanavos I can't select .NET 6 at all as my target framework in the project's settings - only other .net standard versions. .NET 6 itself is installed and I can select it at other project which are currently .NET core 3, but like I said, not for the .net standard projects as it simply doesn't give me the option to select it – CodeMonkey Jul 06 '22 at 11:54
  • I meant changing the version in the csproj file itself, from `netstandard2.0` to `net6.0`. It's not just that .NET 6 is .NET Core 6. In .NET (Core) 5 and 6 there's no longer a need for .NET Standard, as the base runtime itself is cross-platform. To get platform-specific runtimes you need to specify them eg with `net6.0-windows`. Why don't you just use the library as is though? Why do you want to upgrade to .NET 6.0? Do you want to use some newer classes or Core-only packages? – Panagiotis Kanavos Jul 06 '22 at 11:58
  • To understand the changes in .NET Standard check [The Future of .NET Standard](https://devblogs.microsoft.com/dotnet/the-future-of-net-standard/). In short `net5.0. This is for code that runs everywhere. It combines and replaces the netcoreapp and netstandard names. ` – Panagiotis Kanavos Jul 06 '22 at 12:00
  • 3
    They redesigned the Project > Property tool page in VS2022 and it is currently rather brain-damaged. Work around it by right-clicking the project in the Solution Explorer window > Edit Project File > change the TargetFramework element to "net6.0" – Hans Passant Jul 06 '22 at 12:13
  • @HansPassant if you add it as an answer, i will accept it – CodeMonkey Jul 07 '22 at 12:49

3 Answers3

32

I eventually simply edited the project file directly. To convert it to .net 6 all you need to do is change the <TargetFramework> to be like this:

<TargetFramework>net6.0</TargetFramework>

It's a 3 seconds work so no need for any tools

CodeMonkey
  • 11,196
  • 30
  • 112
  • 203
5

.NET standard works parallelly. That means you would have to update to .NET standard 2.1 if you need it for other old framework projects. Otherwise create new libraries in .NET 6 and migrate your code. According to microsoft: https://dotnet.microsoft.com/en-us/platform/dotnet-standard, .NET 6 supports .NET Standard 2.1. Future versions of .NET will also support .NET Standard 2.1 and earlier versions.

mike
  • 1,202
  • 1
  • 7
  • 20
2

The interface Project > Property tools isn't the way to update version from .Net standard to other versions other than standard versions. The right/easiest way is updating the TargetFramework in .csproj file of the project directly.

Ferhi Malek
  • 484
  • 4
  • 15