I have a few dozen NuGet packages published. Most target .NET Standard. Visual Studio makes it very easy to update these packages each time I compile.
Now, I'd like to upgrade these packages to take full advantage of .NET 5.0. But I want the existing ones to still be available for those unable to upgrade to .NET 5.0. Also, I don't want to create completely new packages, such that I have two versions of each one.
If I'm not mistaken, a NuGet package can target multiple framework versions, and I think Visual Studio will automatically load the correct one when installed into a project. However, creating multiple package targets isn't baked into Visual Studio.
I don't know if there are any NuGet package experts here. I would like information about if this is possible, what's the easiest way to accomplish it, how to you handle versioning, etc. Any good book or article references?
Additional Notes
I know I can target multiple frameworks at the project level (using the TargetFrameworks
element in the project file). But then I have to fill my code if #if
, else
, endif
blocks to take advantage of each target framework. I don't think I want this. My library method signatures will change to take advantage of things like nullable strings. I want to be able to do this freely without create multiple versions of everything.