Had the same problem with a project previously opening, compiling and running correctly from VS2022 IDE. The project was originaly placed inside a OneDrive folder, to fix the issue just move the project folder to a different path not inside the OneDrive folder.
Hope this help.