Command Line Interface (CLI)

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

The documentation can be found here.

Getting Started

  • To be able to call UE4Editor.exe or UE4Editor-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}

  • Wher 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 form 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 UE4Editor-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 allow 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 bulding all maps that exist in a project:

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

A forum dicussion with additional info can be found here.

Pitfalls

Some erros that can occure 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 pipelinejust hangs. This can happen with almost all the errors that occurs.

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.