Upgrading netstandard 2.0 class library to dotnet 6
Asked Answered
H

2

11

I am upgrading a dotnet core 3.1 web app to dotnet core 6 which, of course, includes this change:

- <TargetFramework>netcoreapp3.1</TargetFramework>
+ <TargetFramework>net6.0</TargetFramework>

Now, with the class libraries, should I also replace the netstandard reference, too? Eg:

- <TargetFramework>netstandard2.1</TargetFramework>
+ <TargetFramework>net6.0</TargetFramework>
Hartnett answered 23/5, 2022 at 13:1 Comment(3)
I am using netstandard2.0 that works with any version net and net core.Tigrinya
netstandard2.1 is really only useful if you want to prevent the library from being used in a legacy .NETFramework solution.Grecize
Yes, if you do not need any backward compatibility with .NET Core 3.1, that is the way to go. For more information about which TFM's to use nowadays, see this linkCercaria
R
4
- <TargetFramework>netstandard2.1</TargetFramework>
+ <TargetFramework>net6.0</TargetFramework>

That works on mine. As Xinlin answer, just change it then update the nuget packages accordingly.

As my concern changing it was because I've to use dbcontext from the main app (netcore). By keeping it netstandard2.1 makes it fail to get the dbcontext (maybe because it uses different EFCore version, CMIIW)

Reube answered 28/7, 2022 at 10:15 Comment(0)
C
1

I just completed migrating .NET Standard Library 2.1 to .NET 6 for my project.

  1. Changing this line of code in the project file. Change the target framework to net6.0
  2. Update all Nuget packages in the project to match the .Net Core 6 version.
Chieftain answered 13/7, 2022 at 14:53 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Bruton

© 2022 - 2024 — McMap. All rights reserved.