For me, the solution was to go to MyProjectEditor.Target.cs and change the line:
DefaultBuildSettings = BuildSettingsVersion.V2
to
DefaultBuildSettings = BuildSettingsVersion.V4
(The only difference is the changing of “V2” to “V4”.) My project compiled after this change.
EDIT: As of Unreal 5.4, you now have to set DefaultBuiltSettings to BuiltSettingsVersion.V5 or BuildSettingsVersion.Latest