Search code examples
unreal-engine4unreal-blueprint

Unreal Error: Game target is required with -cook or -cookonthefly


On Unreal Engine 4.26.2, I am trying to package a Blueprint/C++ mixture project for Win64.

However, I have encountered the following error:

LogMainFrame: Project does not require temp target
LogLauncherProfile: Found promoted target with matching version at ../../../Engine/Binaries/Win64/UE4Game-Win64-Shipping.target
UATHelper: Packaging (Windows (64-bit)): Running AutomationTool...
UATHelper: Packaging (Windows (64-bit)): Parsing command line: -ScriptsForProject="C:/Users/Administrator/Documents/Unreal Projects/foo.uproject" BuildCookRun -nocompileeditor -installed -nop4 -project="C:/Users/Administrator/Documents/Unreal Projects/foo.uproject" -coo
k -stage -archive -archivedirectory=C:/Users/Administrator/Desktop/Win32UnrealBuilds -package -ue4exe="C:\Program Files\Epic Games\UE_4.26\Engine\Binaries\Win64\UE4Editor-Cmd.exe" -ddc=InstalledDerivedDataBackendGraph -pak -prereqs -nodebuginfo -targetplatform=Win64 -clientconfig=Shipping -utf8output
UATHelper: Packaging (Windows (64-bit)): Setting up ProjectParams for C:\Users\Administrator\Documents\Unreal Projects\foo.uproject
UATHelper: Packaging (Windows (64-bit)): ERROR: Game target not found. Game target is required with -cook or -cookonthefly
UATHelper: Packaging (Windows (64-bit)):        (see C:\Users\Administrator\AppData\Roaming\Unreal Engine\AutomationTool\Logs\C+Program+Files+Epic+Games+UE_4.26\Log.txt for full exception trace)
PackagingResults: Error: Game target not found. Game target is required with -cook or -cookonthefly
UATHelper: Packaging (Windows (64-bit)): AutomationTool exiting with ExitCode=1 (Error_Unknown)
UATHelper: Packaging (Windows (64-bit)): BUILD FAILED
PackagingResults: Error: Unknown Error

The relevant section of the full exception trace is:

BuildCookRun.SetupParams: Setting up ProjectParams for C:\Users\Administrator\Documents\Unreal Projects\foo.uproject
InternalUtils.SafeFileExists: SafeFileExists C:\Users\Administrator\AppData\Local\Temp\UAT\C+Program+Files+Epic+Games+UE_4.26\Rules\UATRules24283721.dll=False
DynamicCompilation.RequiresCompilation: Compiling C:\Users\Administrator\AppData\Local\Temp\UAT\C+Program+Files+Epic+Games+UE_4.26\Rules\UATRules24283721.dll: Assembly does not exist
...
Program.Main: AutomationTool exiting with ExitCode=1 (Error_Unknown)

Is there a conventional reason "Game target not found" is hit?


Solution

  • Although not clear why it worked, copying the default projectname.Target.cs file in the Source directory and renaming it projectnameGame.Target.cs (and also change the internal class name of that file to match) seemed to do the trick. There are now 3 Target.cs files in the Source directory.

    • projectname.Target.cs
    • projectnameGame.Target.cs
    • projectnameEditor.Target.cs

    At that point everything worked again... this seems weird but it works!