Package an Unreal Engine project from the command line
The BuildCookRun command for Windows, Linux and Android, what each flag does, and what to check when it fails.
Clicking Package Project in the editor is fine until you want builds to happen without you: on a build machine, from a script, or after every commit. Behind that button, the editor runs a tool called the Unreal Automation Tool, or UAT. You can run it yourself.
The command
Here's a full build with a launcher-installed engine. Swap in your own engine version and paths:
"C:\Program Files\Epic Games\UE_5.4\Engine\Build\BatchFiles\RunUAT.bat" BuildCookRun ^
-project="C:\Projects\MyGame\MyGame.uproject" ^
-platform=Win64 ^
-clientconfig=Development ^
-build -cook -stage -pak -archive ^
-archivedirectory="C:\Builds\MyGame" ^
-noP4 -unattended -utf8output./Engine/Build/BatchFiles/RunUAT.sh BuildCookRun \
-project="$HOME/Projects/MyGame/MyGame.uproject" \
-platform=Linux \
-clientconfig=Development \
-build -cook -stage -pak -archive \
-archivedirectory="$HOME/Builds/MyGame" \
-noP4 -unattended -utf8outputWhen it's done, your game is in the archive folder, inside a subfolder named after the platform, like Windows or Linux.
What the flags mean
It looks like a lot, but most of the flags just switch on the steps you want, in this order:
The rest:
-platformis what you're building for:Win64,Linux,Androidand so on.-clientconfigis the build configuration. UseDevelopmentwhile testing andShippingfor release.-noP4stops UAT from looking for Perforce. Keep it unless you want Perforce info baked into the build.-unattendedmakes sure nothing waits for someone to click a button. You need it on a build machine.-utf8outputkeeps the log readable when another program captures it.
A few more you might want:
-prereqsadds Unreal's prerequisites installer to Windows builds, which helps players who don't have the right runtimes.-nodebuginfoleaves out debug symbols for a smaller build.-cleanthrows away previous results and rebuilds everything. It's slow, so use it when something seems stale, not every time.
Android
Android needs one extra flag, -cookflavor, which picks the texture format. ASTC works on most modern phones:
RunUAT.bat BuildCookRun -project="C:\Projects\MyGame\MyGame.uproject" ^
-platform=Android -cookflavor=ASTC ^
-clientconfig=Development ^
-build -cook -stage -pak -archive -archivedirectory="C:\Builds\MyGame" ^
-noP4 -unattended -utf8outputThe machine also needs the Android SDK, NDK and JDK versions your engine expects. If you can already package for Android from the editor on that machine, you're set. If not, see Android setup.
Dedicated servers
For a server build, swap the client flags for server ones:
RunUAT.bat BuildCookRun -project="C:\Projects\MyGame\MyGame.uproject" ^
-server -noclient -serverplatform=Linux -serverconfig=Development ^
-build -cook -stage -pak -archive -archivedirectory="C:\Builds\MyGameServer" ^
-noP4 -unattended -utf8outputThis only works with an engine built from source, and your project needs a MyGameServer.Target.cs file in its Source folder. With the launcher version of the engine you'll get "Couldn't find target rules file", and no flag will fix that.
When it fails
The last line of the log is usually just a summary. Scroll up, or search for the first Error:. That's almost always the real problem.
On Windows with a launcher engine, the full logs are in %AppData%\Unreal Engine\AutomationTool\Logs.
Some common ones:
- A cook error naming an asset. The asset is usually broken or references something that was deleted. Open it in the editor, fix any warnings, and save it again.
- Compile errors you don't get in the editor. Often code that only runs in
Shipping, or a missing#includethat the editor's build happened to cover for.
For more, see Packaging errors, explained.
Running it on every commit
Once the command works on your machine, the obvious next step is running it automatically, so every push gives your team a fresh build to test.
Your own build machine
Jenkins, TeamCity, Epic's Horde or a self-hosted GitHub Actions runner. Full control, but someone has to keep the machine, engine installs and disk space in shape.
Unreal Cloud
Runs this same command for you on cloud machines with the engine already installed. Connect GitHub or Perforce, and every push gives you a build to download.
Set up Perforce for an Unreal Engine build machine
The Perforce settings that make an Unreal build machine reliable, from the typemap to login tickets and firewall rules.
Unreal Engine packaging errors, explained
What ExitCode=25, ExitCode=6, Unknown Cook Failure, LNK2019, Live Coding and other Unreal Engine packaging errors mean, how to find the real error, and how to fix the common ones.