Package executable name

Hello there,

We would like to know whether there is a specific location in the engine source code where the game output executable name is defined, allowing us to modify the name of the generated game binary?

Or any process other than migrating the entire project to a newly named project?

For instance, instead of having MyGame-Win64-Shipping.exe we would need to have MyGame.exe or any other name that might be more relevant when the game ships to the public.

Thanks

Hi Simon,

The safest way to change the name of the executable that UnrealBuildTool generates is to rename the project. Thankfully, in the latest UE versions, this should be straightforward as noted in [this short [Content removed]

When you package through the Editor UI, UBT generates the decorated “MyGame-Win64-Shipping.exe” as the main executable, but the staging phase also generates an undecorated bootstrapper “MyGame.exe”, which should serve as the top-level executable for your users. You can also rename the bootstrapper as desired, either manually or through some other script.

Note that it is possible to instruct UnrealBuildTool to generate a custom-named main executable, but this does not generally play well with staging and other packaging phases as triggered from the Editor UI. If you want to try it, you can edit your .Target.cs file and include the following line inside the class constructor:

Name = "MyCustomName";Finally, if you’d like to dive straight into the source code, the binary filename is generated at the end of the following call chain (but note that other build products also go through it):

UnrealBuildTool.UEBuildTarget.PreBuildSetup(Microsoft.Extensions.Logging.ILogger Logger) Line 4460
 UnrealBuildTool.UEBuildTarget.SetupBinaries(Microsoft.Extensions.Logging.ILogger Logger) Line 6085
  UnrealBuildTool.UEBuildTarget.MakeBinaryPaths(EpicGames.Core.DirectoryReference BaseDirectory, string BinaryName, UnrealBuildTool.UnrealTargetPlatform Platform, UnrealBuildTool.UnrealTargetConfiguration Configuration, UnrealBuildTool.UEBuildBinaryType BinaryType, UnrealBuildTool.UnrealArchitectures Architectures, UnrealBuildTool.UnrealTargetConfiguration UndecoratedConfiguration, string ExeSubFolder, EpicGames.Core.FileReference ProjectFile, UnrealBuildTool.ReadOnlyTargetRules Rules) Line 5491
   UnrealBuildTool.UEBuildTarget.MakeBinaryFileName(string BinaryName, string Separator, UnrealBuildTool.UnrealTargetPlatform Platform, UnrealBuildTool.UnrealTargetConfiguration Configuration, UnrealBuildTool.UnrealArchitectures Architectures, UnrealBuildTool.UnrealTargetConfiguration UndecoratedConfiguration, UnrealBuildTool.UEBuildBinaryType BinaryType) Line 5438

I hope this is helpful. Let me know if one of these solutions works for you and if there is anything else I can assist you with.

Best regards,

Vitor

Hi Vito,

Thanks for your answer, this is very helpful.

I tried to override the ‘Name’ property in .Target.cs file but unfortunately doing this make the staging step fails during packaging with the following error:

Stage Failed. Missing receipt ‘<Path>\Binaries\<Platform>\OldGameName-Platform-Shipping.target’. Check that this target has been built.

Which means that, even with the project Name overridden, it seems that there are still some operations during packaging that relies on the old project name.

Hi Simon,

You are right, overriding the name of the Target in the way I mentioned before only works for UnrealBuildTool, but the Staging phase executed by the Editor’s Packaging process has problems with it. Building, Staging and other phases in this process are orchestrated by UnrealAutomationTool.

I looked into the code that performs the Staging, and I think I managed to get it to work with an overriden target name. Please try this: in file [CopyBuildToStagingDirectory.Automation.cs], function CreateDeploymentContext(), look for these lines:

List<StageTarget> TargetsToStage = new List<StageTarget>();
foreach (var TargetAndConfig in TargetAndConfigPairs)
{
	string Target = TargetAndConfig.Item1;
	(...)

After “Target” is defined, define another variable “TargetRulesName” like so:

List<StageTarget> TargetsToStage = new List<StageTarget>();
foreach (var TargetAndConfig in TargetAndConfigPairs)
{
	string Target = TargetAndConfig.Item1;
	string TargetRulesName = Target;
	foreach (var ProjectTarget in Params.ProjectTargets)
	{
		if (Target == ProjectTarget.TargetName)
		{
			TargetRulesName = ProjectTarget.Rules.Name;
			break;
		}
	}
	(...)

Now look for the following line:

FileReference ReceiptFileName = TargetReceipt.GetDefaultPath(ReceiptBaseDir, Target, ReceiptPlatform, Config, Architecture);And change it to use “TargetRulesName” instead of “Target”:

FileReference ReceiptFileName = TargetReceipt.GetDefaultPath(ReceiptBaseDir, TargetRulesName, ReceiptPlatform, Config, Architecture);That’s it. In my tests, this seemed to be enough to make Staging go through until the end and produce a custom-named executable and bootstrapper. Note that I only tested on a blank project with no complex build tasks. If your project’s build process needs other tools from UAT, they might also not be prepared to work with an overriden target name. If you encounter any other problems, it is probably best to avoid this override and just rename the project as mentioned before.

Best regards,

Vitor