I want to copy a file to the same directory as the packaged .exe and I was wondering if it was possible to do this automatically. Is there some way to trigger a script to run once the packaging process is finished ?
Hi,
The Editor itself doesn’t support this, but if you always want to copy an arbitrary file beside the executable you could use runtimedependencies in your build.cs:
D:\UE_5.4\Samples\Games\Lyra\Source\LyraGame\LyraGame.Build.cs
public LyraGame(ReadOnlyTargetRules Target) : base(Target) { ... string SrcFile = "C:/Temp/Image.png"; RuntimeDependencies.Add(Path.Combine("$(TargetOutputDir)", "SomeFileCopiedAsideExe.png"), SrcFile); ... }
If you copy .dll, then you need to be careful that the .dll is not locked by the running Editor for example. But that’s a nice way to copy file with the executable. They are various example in the engine for that, most copying .dll… but I tested the code above for Lyra and my image got copied with the .exe. If you absolutely need to copy the file after the packaging, then you might want to change UAT. This should be this code.
D:\UE_5.4\Engine\Source\Programs\AutomationTool\Scripts\PackageCommand.Automation.cs
`if (bShouldPackage)
{
Logger.LogInformation(“********** PACKAGE COMMAND STARTED YES PATRICK**********”);
var StartTime = DateTime.UtcNow;
foreach (var SC in DeployContextList)
{
if (Params.Package || (SC.StageTargetPlatform.RequiresPackageToDeploy(Params) && Params.Deploy))
{
if (SC.CustomDeployment == null || !SC.CustomDeployment.PrePackage(Params, SC, WorkingCL))
{
SC.StageTargetPlatform.Package(Params, SC, WorkingCL);
}
SC.CustomDeployment?.PostPackage(Params, SC, WorkingCL);
}
}
Logger.LogInformation(“Package command time: {0:0.00} s”, (DateTime.UtcNow - StartTime).TotalMilliseconds / 1000);
Logger.LogInformation(“********** PACKAGE COMMAND COMPLETED **********”);
}`Regards,
Patrick