C
C#17mo ago
Kiel

✅ Making a library as accessible for different .NET versions as possible

I'm developing a simple library meant to be an API wrapper for .NET projects that might want to access it. I'd like it to be usable by as many versions of .NET as possible within reason. What should I target? should I target multiple versions? .NET Standard? I've seen some libraries use multi-targeting and then #if blocks for newer-version features, so I guess that's a possibility too? Or should I just not care and expect users to upgrade/update in order to encourage people not staying on ancient versions?
7 Replies
Zombie
Zombie17mo ago
If you want maximum compatibility, target .NET Standard 2.0. If you want a little bit less compatibility, but more flexibility in what you can write, target .NET Standard 2.1 Otherwise, multi-target your library Then you can have your cake and eat it too
atakancracker
atakancracker17mo ago
here you can see netstandard2.0 and other netstandard versions compatiblity to other targets https://learn.microsoft.com/en-us/dotnet/standard/net-standard?tabs=net-standard-2-0 netstandard2.0 is quite best option I suppose
mtreit
mtreit17mo ago
If by "little bit less compatibility" you mean "no .NET Framework at all" :/
teauxfu
teauxfu17mo ago
what does framework do that core doesn't?
mtreit
mtreit17mo ago
Runs large legacy codebases
Kiel
Kiel17mo ago
Thanks for the suggestions all, I think I'll go with .NET Standard 2.0. I'm working with really simple API endpoints and simple JSON models, so it will probably not be a big issue blobthumbsup
Accord
Accord17mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.