When I open my visual studio 2022 preview recently, I frequently got this error message from the last time I upgraded my VS 2022 preview, I’ve tried all the known ways online, none of them worked.
Finally, I tried to create a new console project and solution, and then, I readded all the projects that was reported the root-level-invalid problem to the new solution, well, it’s working again, surprise.
Hope this could also save your time.