In my case I had also no luck just doing what I did here. Then I remembered that I had uninstalled VS 2017 and then I opened up VS 2019 and realized that some components was not installed in VS 2019 even though I had ticked them off back then in VS 2022. The reason for this seems to be that when removing VS 2017 it also removed those needed .NET and SDK files. As I modified the installed VS 2019 version to also included the shown options above after having verified my UE5.1 installation my VS 2022 suddenly worked again and instantly prop me for installing the VS integration plugin as well.
In worst case then reinstall all VS versions as well as verify the UE5 engine. Hope this works out.