Difficulty with RebuildLightMaps

So I’ve been attempting to set up an automated system that’ll rebuild the lighting in our project. However, I’ve been having some trouble getting RebuildLightMaps to work correctly.

If I use the following command via a build tool that I’ve set up:

D:\P4\WorkSpace\Engine\Build\BatchFiles\RunUAT.bat RebuildLightMaps -project=.\GameFolder\Game.uproject -platform=Win64 -quality=Preview

I get the following error and stack trace:

Log.WriteException: BuildException: No target name was specified on the command-line.
Log.WriteException:    at UnrealBuildTool.TargetDescriptor.ParseCommandLine(String[] Arguments, Boolean bUsePrecompiled, Boolean bSkipRulesCompile, FileReference& ProjectFile) in D:\P4\WorkSpace\Engine\Source\Programs\UnrealBuildTool\Configuration\TargetDescriptor.cs:line 207
Log.WriteException:    at UnrealBuildTool.UnrealBuildTool.RunUBT(BuildConfiguration BuildConfiguration, String[] Arguments, FileReference ProjectFile, Boolean bCatchExceptions) in D:\P4\WorkSpace\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.cs:line 1136

I’m unsure what exactly its looking for, as I think i’ve followed the examples I’ve seen online, but they might have been for older versions of the engine. Adding a -TargetType=Program, ie, the argument it seems to be looking for according to the code in the stack trace, doesn’t seem to affect this error.

Is there an example of this command in use anywhere, or is there something obvious that I’ve left out? I believe my paths are right, given that other commands via our build tool work fine for the files, but I don’t know what else I could be missing.

So I went and read the code for the command, thinking perhaps that I’d forgotten to add a parameter, and it turns out I had. You need to give it the parameter -CommandletTargetName=UnrealLightMass, and also -Submit as it will fail to submit to perforce otherwise.

Hopefully this’ll appear somewhat highly in results for this subject, so you should also know that the command will fail outright if one of the maps you’re trying to build is unable to be accessed. We have exclusive checkout of .umap assets, so I was hoping it would just skip over the map and let you know in the log it had done so, but unfortunately not.