UE5.1 can't package : startIndex cannot be larger than length of string

==============================================================================
ERROR: System.ArgumentOutOfRangeException: startIndex cannot be larger than length of string. (Parameter 'startIndex')
          at System.String.Substring(Int32 startIndex, Int32 length)
          at AutomationScripts.Project.OrderFile..ctor(FileReference FileRef, OrderFileType InType, Int32 SpecIndex, Int32 InPriority) in C:\Program Files\Epic Games\UE_5.1\Engine\Source\Programs\AutomationTool\Scripts\CopyBuildToStagingDirectory.Automation.cs:line 60
          at AutomationScripts.Project.CreatePaks(ProjectParams Params, DeploymentContext SC, List`1 PakParamsList, CryptoSettings CryptoSettings, FileReference CryptoKeysCacheFilename) in C:\Program Files\Epic Games\UE_5.1\Engine\Source\Programs\AutomationTool\Scripts\CopyBuildToStagingDirectory.Automation.cs:line 2889
          at AutomationScripts.Project.CreatePakUsingStagingManifest(ProjectParams Params, DeploymentContext SC) in C:\Program Files\Epic Games\UE_5.1\Engine\Source\Programs\AutomationTool\Scripts\CopyBuildToStagingDirectory.Automation.cs:line 2331
          at AutomationScripts.Project.ApplyStagingManifest(ProjectParams Params, DeploymentContext SC) in C:\Program Files\Epic Games\UE_5.1\Engine\Source\Programs\AutomationTool\Scripts\CopyBuildToStagingDirectory.Automation.cs:line 4206
          at AutomationScripts.Project.CopyBuildToStagingDirectory(ProjectParams Params) in C:\Program Files\Epic Games\UE_5.1\Engine\Source\Programs\AutomationTool\Scripts\CopyBuildToStagingDirectory.Automation.cs:line 4641
          at BuildCookRun.DoBuildCookRun(ProjectParams Params) in C:\Program Files\Epic Games\UE_5.1\Engine\Source\Programs\AutomationTool\Scripts\BuildCookRun.Automation.cs:line 222
          at BuildCookRun.ExecuteBuild() in C:\Program Files\Epic Games\UE_5.1\Engine\Source\Programs\AutomationTool\Scripts\BuildCookRun.Automation.cs:line 42
          at AutomationTool.BuildCommand.Execute() in C:\Program Files\Epic Games\UE_5.1\Engine\Source\Programs\AutomationTool\AutomationUtils\BuildCommand.cs:line 344
          at AutomationTool.BuildCommand.ExecuteAsync() in C:\Program Files\Epic Games\UE_5.1\Engine\Source\Programs\AutomationTool\AutomationUtils\BuildCommand.cs:line 353
          at AutomationTool.Automation.ExecuteAsync(List`1 CommandsToExecute, Dictionary`2 Commands) in C:\Program Files\Epic Games\UE_5.1\Engine\Source\Programs\AutomationTool\AutomationUtils\Automation.cs:line 257
          at AutomationTool.Automation.ProcessAsync(ParsedCommandLine AutomationToolCommandLine, StartupTraceListener StartupListener, HashSet`1 ScriptModuleAssemblies) in C:\Program Files\Epic Games\UE_5.1\Engine\Source\Programs\AutomationTool\AutomationUtils\Automation.cs:line 156
       (see C:\Users\Aum_l\AppData\Roaming\Unreal Engine\AutomationTool\Logs\C+Program+Files+Epic+Games+UE_5.1\Log.txt for full exception trace)

ArgumentOutOfRangeException: startIndex cannot be larger than length of string. (Parameter 'startIndex')
   at System.String.Substring(Int32 startIndex, Int32 length)
   at AutomationScripts.Project.OrderFile..ctor(FileReference FileRef, OrderFileType InType, Int32 SpecIndex, Int32 InPriority) in C:\Program Files\Epic Games\UE_5.1\Engine\Source\Programs\AutomationTool\Scripts\CopyBuildToStagingDirectory.Automation.cs:line 60
   at AutomationScripts.Project.CreatePaks(ProjectParams Params, DeploymentContext SC, List`1 PakParamsList, CryptoSettings CryptoSettings, FileReference CryptoKeysCacheFilename) in C:\Program Files\Epic Games\UE_5.1\Engine\Source\Programs\AutomationTool\Scripts\CopyBuildToStagingDirectory.Automation.cs:line 2889
   at AutomationScripts.Project.CreatePakUsingStagingManifest(ProjectParams Params, DeploymentContext SC) in C:\Program Files\Epic Games\UE_5.1\Engine\Source\Programs\AutomationTool\Scripts\CopyBuildToStagingDirectory.Automation.cs:line 2331
   at AutomationScripts.Project.ApplyStagingManifest(ProjectParams Params, DeploymentContext SC) in C:\Program Files\Epic Games\UE_5.1\Engine\Source\Programs\AutomationTool\Scripts\CopyBuildToStagingDirectory.Automation.cs:line 4206
   at AutomationScripts.Project.CopyBuildToStagingDirectory(ProjectParams Params) in C:\Program Files\Epic Games\UE_5.1\Engine\Source\Programs\AutomationTool\Scripts\CopyBuildToStagingDirectory.Automation.cs:line 4641
   at BuildCookRun.DoBuildCookRun(ProjectParams Params) in C:\Program Files\Epic Games\UE_5.1\Engine\Source\Programs\AutomationTool\Scripts\BuildCookRun.Automation.cs:line 222
   at BuildCookRun.ExecuteBuild() in C:\Program Files\Epic Games\UE_5.1\Engine\Source\Programs\AutomationTool\Scripts\BuildCookRun.Automation.cs:line 42
   at AutomationTool.BuildCommand.Execute() in C:\Program Files\Epic Games\UE_5.1\Engine\Source\Programs\AutomationTool\AutomationUtils\BuildCommand.cs:line 344
   at AutomationTool.BuildCommand.ExecuteAsync() in C:\Program Files\Epic Games\UE_5.1\Engine\Source\Programs\AutomationTool\AutomationUtils\BuildCommand.cs:line 353
   at AutomationTool.Automation.ExecuteAsync(List`1 CommandsToExecute, Dictionary`2 Commands) in C:\Program Files\Epic Games\UE_5.1\Engine\Source\Programs\AutomationTool\AutomationUtils\Automation.cs:line 257
   at AutomationTool.Automation.ProcessAsync(ParsedCommandLine AutomationToolCommandLine, StartupTraceListener StartupListener, HashSet`1 ScriptModuleAssemblies) in C:\Program Files\Epic Games\UE_5.1\Engine\Source\Programs\AutomationTool\AutomationUtils\Automation.cs:line 156
==============================================================================
AutomationTool executed for 0h 0m 20s
AutomationTool exiting with ExitCode=1 (Error_Unknown)

Log.txt (106.6 KB)

I have tried this method

but doesn’t work at all.
I also reinstall the engine, and the same error occurs, even in ThirdPerson template Project.

This error message indicates that there is an issue with the “CopyBuildToStagingDirectory” script in the Unreal Engine’s Automation Tool. Specifically, the error is occurring in the “OrderFile” constructor on line 60, where the “Substring” method is being used to extract a portion of a string, but the “startIndex” parameter is larger than the length of the string. This suggests that there is a problem with the input being passed to this constructor, and that the string being passed in as an argument may not be of the expected length.

One possible cause of this issue could be a problem with the project configuration, where the path to the files being processed by the script is incorrect. It is also possible that there is a bug in the script itself, or that there is an issue with the version of the engine that you are using.

I recommend checking your project configuration and making sure that the paths being passed to the script are correct, and also verifying that you are using the latest version of the engine. Additionally, checking the Unreal Engine’s issue tracker or forum to see if there are any known issues related to this error message. If the problem persists, you may need to contact Unreal Engine’s technical support for further assistance.

After spending some time reading the log and going through the UE source code, I have finally found that it is about setting pak file, so I just don’t use it when packaging.
Now I can finally build it successfully.

But still waiting for the detailed answer, why this happens to me.

@AumieJaE Hey, my friend.
I just accidentally fix this problem this morning.
What it has to do is “dotnet things” which has a bug when run from a machine with use non-standard region DateTime.

I changed Windows Regional Format to [English United States] and restarted the computer. Then I packaged the project successfully at least 2 times. I will try with my working project today too.

Maybe this can solve your issue too.

This is the link they’re talking about “dotnet things”
https://github.com/dotnet/sdk/issues/23148

Thanks for your …
HELP!!!
:smiley: :smiley: :smiley: :smiley: :smiley: :smiley: :smiley: :smiley: :smiley: :smiley: :smiley: