Changing engine version from 5.1.1 to 5.0.4 The name 'IncludeOrderVersion' does not exist in the current context and others

Hello, when trying to switch version of project from 5.1 to 5.0 i’m getitng erorrs:

Running C:/Program Files/Epic Games/UE_5.0/Engine/Binaries/DotNET/UnrealBuildTool/UnrealBuildTool.exe  -projectfiles -project="D:/Documents/Unreal Projects/ProjectName/ProjectName.uproject" -game -rocket -progress -log="D:\Documents\Unreal Projects\ProjectName/Saved/Logs/UnrealVersionSelector-2023.02.27-12.20.34.log"
Log file: D:\Documents\Unreal Projects\ProjectName\Saved\Logs\UnrealVersionSelector-2023.02.27-12.20.34.log
Log file: C:\Users\UserName\AppData\Local\UnrealBuildTool\Log_GPF.txt

Some Platforms were skipped due to invalid SDK setup: IOS, Android, Linux, LinuxArm64.
See the log file for detailed information

Discovering modules, targets and source code for project...
D:\Documents\Unreal Projects\ProjectName\Source\ProjectName.Target.cs(12,3): error CS0103: The name 'IncludeOrderVersion' does not exist in the current context
D:\Documents\Unreal Projects\ProjectName\Source\ProjectName.Target.cs(12,25): error CS0103: The name 'EngineIncludeOrderVersion' does not exist in the current context
D:\Documents\Unreal Projects\ProjectName\Source\ProjectNameEditor.Target.cs(12,3): error CS0103: The name 'IncludeOrderVersion' does not exist in the current context
D:\Documents\Unreal Projects\ProjectName\Source\ProjectNameEditor.Target.cs(12,25): error CS0103: The name 'EngineIncludeOrderVersion' does not exist in the current context
ERROR: Expecting to find a type to be declared in a target rules named 'ProjectNameTarget'.  This type must derive from the 'TargetRules' type defined by Unreal Build Tool.

I can migrate the broken half-migrate back to 5.1.1 without issue.
When trying to open half-migrated 5.0.4 project, I get:

The following modules are missing or built with a different engine version:
ProjectName
Would you like to rebuild them now?

After pressing “No” the program exits, after pressing “yes”:

ProjectName could not be compiled. Try rebuilding from source manually.

When opening the .sln and doing “build” (as this is what I presume the engine wants me to do) i get:

MS83073 The command "...\Build.bat ...\ProjectName.uproject -WaitMutex -FromMsBuild" exited with code 6.

This is probably because UE5.1 changed the Include Order, so the parameters used in 5.1 Target.cs files do not actually exist in 5.0.

The error that you posted mentions about them all.
Just go to these files and try deleting these lines:

D:\Documents\Unreal Projects\ProjectName\Source\ProjectName.Target.cs(12,3):
'IncludeOrderVersion'

D:\Documents\Unreal Projects\ProjectName\Source\ProjectName.Target.cs(12,25):
'EngineIncludeOrderVersion'

D:\Documents\Unreal Projects\ProjectName\Source\ProjectNameEditor.Target.cs(12,3):
'IncludeOrderVersion'

D:\Documents\Unreal Projects\ProjectName\Source\ProjectNameEditor.Target.cs(12,25):
'EngineIncludeOrderVersion'