Recently got this error “… doesn’t have a target for ‘.NETCoreApp,Version=v2.2’. Ensure that restore has run and that you have included ‘netcoreapp2.2’ in the TargetFrameworks for your project” after upgrading a project from .net core 2.2 to 3.1 then trying to publish the project.
It seems like the publish profile (project/publishprofiles/XXX.pubxml) is not getting updated with the target framework on the GUI.
Fix i found that worked was to edit the profile, switch it to debug, save changes and then switch it back to release. That seemed to update the TargetFramework. In my case, it wasn’t even specified in the XML file.