'Building a net5.0 targeted app which can run on net6.0 runtime

I previously thought the net6.0 runtime was backwards compatible in that net5.0 apps would just run as-is, but that isn't what I'm seeing in testing. My development system is using VS2019, so it does not support the net6.0 SDK. I have tried to manually convert the TargetFramework tag to TargetFrameworks and add net5.0;net6.0, but it won't build. I would love some kind of net5.0+ tag which indicates 5 or later, but I can't find that either.

But why doesn't TargetFramework set to net5.0 work when deployed to a system with only the net6.0 runtime? Let's say my app was built before net6.0 existed. I wouldn't want to have to issue a new package when net6.0 was released. Would this require the customer to keep net5.0 installed indefinitely to keep supporting my app?

I feel like I'm missing something simple, but after several hours of reading I'm not any closer to figuring it out.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source