Command Line Interface (CLI)

A introduction to using the command line for building projects in Unreal Engine

Updated 10 months ago Edit Page Revisions

The documentation can be found here.

Unreal Engine Version

The executables referenced in this document may have different names based on what version of Unreal Engine you are using. This document defaults to utilizing Unreal Engine 5 names.

UE4

For Unreal Engine 4, the executables referenced in this document are called:

  • UE4Editor.exe
  • UE4Editor-Cmd.exe

UE5

For Unreal Engine 5, the executables referenced in this document are called:

  • UnrealEditor.exe
  • UnrealEditor-Cmd.exe

Getting Started

  • To be able to call UnrealEditor.exe or UnrealEditor-Cmd.exe directly from the command line, you should add the folder containing these shortcuts to path. This can be done either through the GUI or through the CLI

  • The folder is often found under C:\\Program Files\\Epic Games\\{UE_Version}\\Engine\\Binaries\\{OS_Version}

    • Where the UE_Version is the version of Unreal Engine you want to link to and OS_Version is what operating system you are using. If you are on Windows, this is most likely Win64.

Building Lighting

The option to build lighting from the command line was added as of version 4.10.2.

Runs a lighting build for specific, or all, map(s). Reusing the ResavePackages commandlet. The commandline for the commandlet is:

ProjectName -run=resavepackages -buildlighting -allowcommandletrendering -map=optionalmapname

Script added to UAT to automate the process. The commandline for this is:

RebuildLightmaps -project="My:/Absolute/Project/Path.uproject" -MapsToRebuildLightMaps=OptionalMapName

An important thing to note is that the UAT script requires Perforce even if the -noP4 flag is set. When using ResavePackages there is no dependency on Perforce. When using Resave packages the ProjectName should also be the absolute project path and should be run with UnrealEditor-Cmd-Cmd.exe before ProjectName.

When using resave packages to build lighting you will need to set certain flags. These commands are not case sensitive.

  • -BuildLighting is the flag to tell ResavePackages that the map needs to be rebuilt with lighting.

  • -AllowCommandletRendering needs to be set or the process won't run, it allows the rendering to be done by the ResavePackages commandlet.

  • -MapsOnly can be used to specify that only lighting for maps should be rebuilt.

  • -ProjectOnly can be used to specify that only object in the project should be rebuilt.

  • -Map=OptionalMapName can be used to select a specific map. Here you switch OptionalMapName for the map you want to build. Remember that this cannot be absolute path name, just map name ex: -map=ExampleMap OR -map=ExampleMap.umap.

  • -Quality can be used to select the quality of the rebuild, this is standard set to Production. The options are Preview/Medium/High/Production/MAX.

  • -IgnoreChangeList can be used so that the build process can be run on mismatched engine versions. It is defined as ignoring package version changelist.

Example of building all maps that exist in a project:

UnrealEditor-Cmd.exe C:\Absolute\Path\To\Project\Project.uproject -Run=ResavePackages -IgnoreChangeList -BuildLighting -Quality=Preview -MapsOnly -ProjectOnly -AllowCommandletRendering

A forum discussion with additional info can be found here.

Pitfalls

Some errors that can occur are the "None" is not a valid path, this may happen because there is a space that is not escaped in the path to the Project or the map name needs to be set in apostrophes as there is a sign that isn't handled correctly.

Some errors may not write the error to the command line, but instead open a pop-up and then open the UE-crash reporting tools. If the process is running in a CI-pipeling, this may be the reason the pipeline just hangs. This can happen with almost all the errors that occur.

Depending on how your project is set up, when build lighting for maps you may run into the problem that only the last map that was built has lighting built. This may be because they share some parts and these parts are rebuilt when you build each map. See Lighting Scenarios for how to fix this. It can also be noted if the map only has one scenario but shares other components you can set lighting scenario, but then you need to change streaming method and set always loaded to be able to save that you have changed to Lighting Scenario.