Figured I would add this just in case it can help someone. Hard to find solutions sometimes.
Anyway, the problem :
I was getting the “Project could not be compiled…” error when I would try to open the project from the Unreal Engine ‘hub’ (?) or from the project file in Windows Explorer. However, when I manually compiled the project in Visual Studio, it would complete with no errors. Unreal Editor was not VISIBLY open. However, because it had crashed earlier, it never shut down properly and the process was still running in the background.
The solution :
After opening the Task Manager and ending the Unreal Editor process, I was able to open the project normally, without any code changes. So, you actually may not have any issues with your code or corruption in your project. You may just need to make sure the editor process stopped last time you had the project open. Hope it helps.
Almost forgot. Also, I didn’t have to delete any folders or, as far as I could tell, even rebuild the project. However, in the Editor Preferences I have enabled ‘Force Compilation at Startup’.