RunUAT fails with "couldn't find target rules file for target UnrealHeaderTools"

I’m trying to build the LightingTutorial project from the Windows 10 command line following this wiki page and I’m getting the error pasted below.

Anyone know why this is failing?

UnrealBuildTool: Building UnrealHeaderTool...
UnrealBuildTool: ERROR: Couldn't find target rules file for target 'UnrealHeaderTool' in rules assembly 'UnrealHeaderToolModuleRules, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
UnrealBuildTool: Location: c:\Program Files (x86)\Epic Games\4.8\Engine\Intermediate\Build\BuildRules\UnrealHeaderToolModuleRules.dll
UnrealBuildTool: Target rules found:
UnrealBuildTool:        UE4Editor - c:\Program Files (x86)\Epic Games\4.8\Engine\Source\UE4Editor.Target.cs
UnrealBuildTool:        UE4Game - c:\Program Files (x86)\Epic Games\4.8\Engine\Source\UE4Game.Target.cs
UnrealBuildTool: UnrealHeaderTool failed for target 'LightingTutorial' (platform: Win64, module info: C:\Users\smurthas\Documents\Unreal Projects\LightingTutorial\Intermediate\Build\Win64\LightingTutorial\Development\UnrealHeaderTool.manifest).
CommandUtils.Run: Run: Took 4.6553028s to run UnrealBuildTool.exe, ExitCode=5
ErrorReporter.Error: ERROR: AutomationTool error: Command failed (Result:5): c:\Program Files (x86)\Epic Games\4.8\Engine\Binaries\DotNET\UnrealBuildTool.exe LightingTutorial Win64 Development  "C:\Users\smurthas\Documents\Unreal Projects\LightingTutorial\LightingTutorial.uproject"  -noxge -NoHotReloadFromIDE -ignorejunk. See logfile for details: 'UnrealBuildTool.txt'
BuildCommand.Execute: ERROR: BUILD FAILED
Program.Main: ERROR: AutomationTool terminated with exception:
Program.Main: ERROR: Exception in AutomationTool: Command failed (Result:5): c:\Program Files (x86)\Epic Games\4.8\Engine\Binaries\DotNET\UnrealBuildTool.exe LightingTutorial Win64 Development  "C:\Users\smurthas\Documents\Unreal Projects\LightingTutorial\LightingTutorial.uproject"  -noxge -NoHotReloadFromIDE -ignorejunk. See logfile for details: 'UnrealBuildTool.txt'
Stacktrace:    at AutomationTool.CommandUtils.RunAndLog(String App, String CommandLine, String Logfile, Int32 MaxSuccessCode, String Input, ERunOptions Options, Dictionary`2 EnvVars)
   at AutomationTool.CommandUtils.RunUBT(CommandEnvironment Env, String UBTExecutable, String CommandLine, String LogName, Dictionary`2 EnvVars)
   at AutomationTool.UE4Build.BuildWithUBT(String ProjectName, String TargetName, UnrealTargetPlatform TargetPlatform, String Config, String UprojectPath, Boolean ForceMonolithic, Boolean ForceNonUnity, Boolean ForceDebugInfo, Boolean ForceFlushMac, Boolean DisableXGE, String InAddArgs, Boolean ForceUnity, Dictionary`2 EnvVars)
   at AutomationTool.UE4Build.Build(BuildAgenda Agenda, Nullable`1 InDeleteBuildProducts, Boolean InUpdateVersionFiles, Boolean InForceNoXGE, Boolean InForceNonUnity, Boolean InForceUnity, Dictionary`2 PlatformEnvVars)
   at Project.Build(BuildCommand Command, ProjectParams Params, Int32 WorkingCL)
   at BuildCookRun.DoBuildCookRun(ProjectParams Params)
   at BuildCommand.Execute()
   at AutomationTool.Automation.Execute(List`1 CommandsToExecute, CaselessDictionary`1 Commands)
   at AutomationTool.Automation.Process(String[] CommandLine)
   at AutomationTool.Program.MainProc(Object Param)
   at AutomationTool.InternalUtils.RunSingleInstance(MainProc Main, Object Param)
   at AutomationTool.Program.Main()
Program.Main: ERROR: Command failed (Result:5): c:\Program Files (x86)\Epic Games\4.8\Engine\Binaries\DotNET\UnrealBuildTool.exe LightingTutorial Win64 Development  "C:\Users\smurthas\Documents\Unreal Projects\LightingTutorial\LightingTutorial.uproject"  -noxge -NoHotReloadFromIDE -ignorejunk. See logfile for details: 'UnrealBuildTool.txt'

The command I’m running is this:

RunUAT BuildCookRun -project="full_project_path_and_project_name.uproject" -noP4 -platform=Win64 -clientconfig=Development -serverconfig=Development -cook -allmaps -build -stage -pak -archive -archivedirectory="Output Directory"

Hello,

What is the exact command that you are running to attempt to package your game?

I was able to get this running after tinkering with several settings and options. Here’s my wrapper batch file for this:

SET projectName=REPLACE_THIS_W_YOUR_PROJ_NAME
SET outputDir=%USERPROFILE%"\unreal-dist"

pushd "C:\Program Files (x86)\Epic Games\4.8\Engine\Build\BatchFiles

RunUAT BuildCookRun -project=%USERPROFILE%"\Documents\Unreal Projects\%projectName%\%projectName%.uproject" -noP4 -platform=Win64 -clientconfig=Development -serverconfig=Development -cook -rocket -allmaps -build -stage -NoCompile -pak -archive -archivedirectory=%outputDir%

popd

A couple things I did in the process:

  1. It seemed possibly important that the RunUAT script be executed from within its own directory, hence the pushd/popd.
  2. It seemed possibly important that my project lived in %USERPROFILE%"\Documents\Unreal Projects.
  3. I added the -rocket and -nocompile options, which seem to be related to having installed the engine from the Epic Games Launcher.

RunUAT seems to be completely undocumented, so this was really a multiday trial-and-error process.

I hope this helps someone fix a similar issue in the future!

Sean, I updated the original question with the command and since I recently solved with for my own situation, I posted an answer.