Packaging Error : Couldn't update resource

Hi,

It’s the first time I’m trying to package since moving my project from 4.5 to 4.7.1. I’m pretty sure this most be a minor error since my game compiles and the cooking process also seems to be working fine, but I can’t seem to find what is the issue, and the error is not very telling (or at least, I don’t know what it means!).

So basically, the packaging fails at the end of the process with the “Couldn’t update resource” error. I have put the relevant stack here :

[2015.04.07-14.08.11:501][259]MainFrameActions: Packaging (Windows (64-bit)): BuildCommand.Execute: ERROR: BUILD FAILED

[2015.04.07-14.08.11:502][259]MainFrameActions: Packaging (Windows (64-bit)): Program.Main: ERROR: AutomationTool terminated with exception:

[2015.04.07-14.08.11:502][259]MainFrameActions: Packaging (Windows (64-bit)): Program.Main: ERROR: Exception in Win.Automation: Couldn't update resource

[2015.04.07-14.08.11:502][259]MainFrameActions: Packaging (Windows (64-bit)): Stacktrace:    à ModuleResourceUpdate.SetData(Int32 ResourceId, ResourceType Type, Byte[] Data) dans c:\Users\mdube\Perforce\prodperforce\Jotunn\EngineFrima\Engine\Source\Programs\AutomationTool\Win\WinPlatformResources.Automation.cs:ligne 254

[2015.04.07-14.08.11:502][259]MainFrameActions: Packaging (Windows (64-bit)):    à ModuleResourceUpdate.SetIcons(Int32 ResourceId, GroupIconResource GroupIcon) dans c:\Users\mdube\Perforce\prodperforce\Jotunn\EngineFrima\Engine\Source\Programs\AutomationTool\Win\WinPlatformResources.Automation.cs:ligne 264

[2015.04.07-14.08.11:502][259]MainFrameActions: Packaging (Windows (64-bit)):    à BaseWinPlatform.StageBootstrapExecutable(DeploymentContext SC, String TargetFile, String StagedRelativeTargetPath, String StagedArguments) dans c:\Users\mdube\Perforce\prodperforce\Jotunn\EngineFrima\Engine\Sour
[2015.04.07-14.08.11:502][259]MainFrameActions: Packaging (Windows (64-bit)): ce\Programs\AutomationTool\Win\WinPlatform.Automation.cs:ligne 215

[2015.04.07-14.08.11:502][259]MainFrameActions: Packaging (Windows (64-bit)):    à BaseWinPlatform.GetFilesToDeployOrStage(ProjectParams Params, DeploymentContext SC) dans c:\Users\mdube\Perforce\prodperforce\Jotunn\EngineFrima\Engine\Source\Programs\AutomationTool\Win\WinPlatform.Automation.cs:ligne 149

[2015.04.07-14.08.11:502][259]MainFrameActions: Packaging (Windows (64-bit)):    à Win64Platform.GetFilesToDeployOrStage(ProjectParams Params, DeploymentContext SC) dans c:\Users\mdube\Perforce\prodperforce\Jotunn\EngineFrima\Engine\Source\Programs\AutomationTool\Win\WinPlatform.Automation.cs:ligne 352

[2015.04.07-14.08.11:502][259]MainFrameActions: Packaging (Windows (64-bit)):    à Project.CreateStagingManifest(ProjectParams Params, DeploymentContext SC) dans c:\Users\mdube\Perforce\prodperforce\Jotunn\EngineFrima\Engine\Source\Programs\AutomationTool\Scripts\CopyBuildToStagingDirectory.Automation.cs:ligne 228

[2015.04.07-14.08.11:502][259]MainFrameActions: Packaging (Windows (64-bit)):    à Project.CopyBuildToStagingDirectory(ProjectParams Params) dans c:\Users\mdube\Perforce\prodperforce\Jotunn\EngineFrima\Engine\Source\Programs\AutomationTool\Scripts\CopyBuildToStagingDirectory.Automation.cs:ligne 1325

[2015.04.07-14.08.11:502][259]MainFrameActions: Packaging (Windows (64-bit)):    à BuildCookRun.DoBuildCookRun(ProjectParams Params) dans c:\Users\mdube\Perforce\prodperforce\Jotunn\EngineFrima\Engine\Source\Programs\AutomationTool\Scripts\BuildCookRun.Automation.cs:ligne 253

[2015.04.07-14.08.11:502][259]MainFrameActions: Packaging (Windows (64-bit)):    à BuildCommand.Execute() dans c:\Users\mdube\Perforce\prodperforce\Jotunn\EngineFrima\Engine\Source\Programs\AutomationTool\BuildCommand.cs:ligne 37

[2015.04.07-14.08.11:502][259]MainFrameActions: Packaging (Windows (64-bit)):    à AutomationTool.Automation.Execute(List`1 CommandsToExecute, CaselessDictionary`1 Commands) dans c:\Users\mdube\Perforce\prodperforce\Jotunn\EngineFrima\Engine\Source\Programs\AutomationTool\Automation.cs:ligne 380

[2015.04.07-14.08.11:502][259]MainFrameActions: Packaging (Windows (64-bit)):    à AutomationTool.Automation.Process(String[] CommandLine) dans c:\Users\mdube\Perforce\prodperforce\Jotunn\EngineFrima\Engine\Source\Programs\AutomationTool\Automation.cs:ligne 352

[2015.04.07-14.08.11:502][259]MainFrameActions: Packaging (Windows (64-bit)):    à AutomationTool.Program.MainProc(Object Param) dans c:\Users\mdube\Perforce\prodperforce\Jotunn\EngineFrima\Engine\Source\Programs\AutomationTool\Program.cs:ligne 168

[2015.04.07-14.08.11:502][259]MainFrameActions: Packaging (Windows (64-bit)):    à AutomationTool.InternalUtils.RunSingleInstance(MainProc Main, Object Param) dans c:\Users\mdube\Perforce\prodperforce\Jotunn\EngineFrima\Engine\Source\Programs\AutomationTool\Utils.cs:ligne 705

[2015.04.07-14.08.11:502][259]MainFrameActions: Packaging (Windows (64-bit)):    à AutomationTool.Program.Main() dans c:\Users\mdube\Perforce\prodperforce\Jotunn\EngineFrima\Engine\Source\Programs\AutomationTool\Program.cs:ligne 115

[2015.04.07-14.08.11:502][259]MainFrameActions: Packaging (Windows (64-bit)): Program.Main: ERROR: Couldn't update resource

I would really appreciate some help on this one!

Thanks!

Mick

I found out that for some reason, the .exe in MyGame\Intermediate\Staging was getting copied as Read-Only, even if the original file was not. This is a very strange behavior, and if someone can explain this one, that would be great. Anyways, i’ve implemented a fix that will work in all cases, mainly because I juste remove the Read-Only attribute on the copied file :

In WinPlatform.Automation.cs , the StageBootstrapExecutable function:

After the File.Copy :

File.Copy(InputFile, IntermediateFile, true);

            //Added: After File.Copy, make sure it is not Read only...
            FileAttributes attributes = File.GetAttributes(IntermediateFile);
            if ((attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
            {
                attributes = attributes & ~FileAttributes.ReadOnly;
                File.SetAttributes(IntermediateFile, attributes);
            }

So anyway, that was my issue…weird one…

thank you so much for this fix

I had the exact same issue with 4.8.2 - thank you very much for sharing that workaround.
As for the cause of this problem my first guess would be that it’s related to having the entire engine folder under p4 source control (AFAIK epic is using a special setup internally where most binaries are specifically marked writeable…)

Perhaps a better solution is to make the Engine/Binaries/Win64/BootstrapPackagedGame-Win64-Shipping.exe file writable (+w) in perforce.

The best solution is to follow EPIC’s guidelines for using the typemap in Perforce with UE4 (available only to p4 admins):