Can't package game (an item with the same key has already been added)

I recently switched from 4.8.3 binary to a custom build of the engine (https://github.com/Oculus-VR/UnrealEngine/tree/4.8).

This is what I did:

  • Built the engine (configuration ‘Development Editor’)
  • Converted my project (runs fine in editor)
  • Right-clicked on the *.uproject file, switched unreal engine version to the new build
  • Generated Visual Studio project files
  • Tried to package (shipping/build for distribution) which worked in the binary release
  • After about 10 seconds, the packaging process aborts:

(…)
MainFrameActions: Packaging (Windows (64-bit)): BuildCommand.Execute: ERROR: BUILD FAILED
MainFrameActions: Packaging (Windows (64-bit)): Program.Main: ERROR: AutomationTool terminated with exception:
MainFrameActions: Packaging (Windows (64-bit)): Program.Main: ERROR: Exception in mscorlib: An item with the same key has already been added (translated from German)
MainFrameActions: Packaging (Windows (64-bit)): Stacktrace: bei System.Collections.Generic.Dictionary2.Insert(TKey key, TValue value, Boolean add) MainFrameActions: Packaging (Windows (64-bit)): bei AutomationTool.ProjectUtils.Compil MainFrameActions: Packaging (Windows (64-bit)): eAndLoadTargetsAssembly(ProjectProperties Properties, String TargetsDllFilename, Boolean DoNotCompile, List1 TargetScripts) in d:\Documents\Unreal Projects\VRShowRoom\UE4_Oculus\Engine\Source\Programs\AutomationTool\ProjectUtils.cs:Zeile 521.
MainFrameActions: Packaging (Windows (64-bit)): bei AutomationTool.ProjectUtils.DetectTargetsForProject(ProjectProperties Properties, List1 ExtraSearchPaths) in d:\Documents\Unreal Projects\VRShowRoom\UE4_Oculus\Engine\Source\Programs\AutomationTool\ProjectUtils.cs:Zeile 473. MainFrameActions: Packaging (Windows (64-bit)): bei AutomationTool.ProjectUtils.DetectProjectProperties(String RawProjectPath, List1 ClientTargetPlatforms) in d:\Documents\Unreal Projects\VRShowRoom\UE4_Oculus\Engine\Source\Programs\AutomationTool\ProjectUtils.cs:Zeile 287.
MainFrameActions: Packaging (Windows (64-bit)): bei AutomationTool.ProjectUtils.GetProjectProperties(String RawProjectPath, List1 ClientTargetPlatforms) in d:\Documents\Unreal Projects\VRShowRoom\UE4_Oculus\Engine\Source\Programs\AutomationTool\ProjectUtils.cs:Zeile 127. MainFrameActions: Packaging (Windows (64-bit)): bei AutomationTool.ProjectParams.AutodetectSettings(Boolean bReset) in d:\Documents\Unreal Projects\VRShowRoom\UE4_Oculus\Engine\Source\Programs\AutomationTool\ProjectParams.cs:Zeile 1372. MainFrameActions: Packaging (Windows (64-bit)): bei AutomationTool.ProjectParams..ctor(String RawProjectPath, CommandUtils Command, String Device, String MapToRun, String AdditionalServerMapParams, ParamList1 Port, String RunCommandline, String StageCommandline, String BundleName, String StageDirectoryParam, Nullable1 StageNonMonolithic, String UE4Exe, String SignPak, List1 ClientConfigsToBuild, List1 ServerConfigsToBuild, ParamList1 MapsToCook, ParamList1 DirectoriesToCook, String InternationalizationPreset, ParamList1 CulturesToCook, ParamList1 ClientCookedTargets, ParamList1 EditorTargets, ParamList1 ServerCookedTargets, List1 ClientTargetPlatforms, Dictionary2 ClientDependentPlatformMap, List1 ServerTargetPlatforms, Dictionary2 ServerDependentPlatformMap, Nullable1 Build, Nullable1 Cook, String CookFlavor, Nullable1 Run, Nullable1 SkipServer, Nullable1 Clean, Nullable1 Compressed, Nullable1 UseDebugParamForEditorExe, Nullable1 IterativeCooking, Nullable1 CookAll, Nullable1 CookMapsOnly, Nullable1 CookOnTheFly, Nullable1 CookOnTheFlyStreaming, Nullable1 UnversionedCookedContent, String AdditionalCookerOptions, String BasedOnReleaseVersion, String CreateReleaseVersion, Nullable1 GeneratePatch, String DLCName, Nullable1 DLCIncludeEngineContent, Nullable1 NewCook, Nullable1 OldCook, Nullable1 CrashReporter, Nullable1 DedicatedServer, Nullable1 Client, Nullable1 Deploy, Nullable1 FileServer, Nullable1 Foreign, Nullable1 ForeignCode, Nullable1 LogWindow, Nullable1 NoCleanStage, Nullable1 NoClient, Nullable1 NoDebugInfo, Nullable1 NoXGE, Nullable1 Package, Nullable1 Pak, Nullable1 Prereqs, Nullable1 NoBootstrapExe, Nullable1 SignedPak, Nullable1 NullRHI, Nullable1 FakeClient, Nullable1 EditorTest, Nullable1 RunAutomationTests, String RunAutomationTest, Nullable1 CrashIndex, Nullable1 Rocket, Nullable1 SkipCook, Nullable1 SkipCookOnTheFly, Nullable1 SkipPak, Nullable1 SkipStage, Nullable1 Stage, Nullable1 Manifests, Nullable1 CreateChunkInstall, Nullable1 Unattended, Nullable1 NumClients, Nullable1 Archive, String ArchiveDirectoryParam, Nullable1 ArchiveMetaData, ParamList1 ProgramTargets, Nullable1 Distribution, Nullable1 Prebuilt, Nullable1 RunTimeoutSeconds, String SpecifiedArchitecture, Nullable1 IterativeDeploy) in d:\Documents\Unreal Projects\VRShowRoom\UE4_Oculus\Engine\Source\Programs\AutomationTool\ProjectParams.cs:Zeile 680. MainFrameActions: Packaging (Windows (64-bit)): bei BuildCookRun.SetupParams() in d:\Documents\Unreal Projects\VRShowRoom\UE4_Oculus\Engine\Source\Programs\AutomationTool\Scripts\BuildCookRun.Automation.cs:Zeile 54. MainFrameActions: Packaging (Windows (64-bit)): bei BuildCookRun.ExecuteBuild() in d:\Documents\Unreal Projects\VRShowRoom\UE4_Oculus\Engine\Source\Programs\AutomationTool\Scripts\BuildCookRun.Automation.cs:Zeile 43. MainFrameActions: Packaging (Windows (64-bit)): bei BuildCommand.Execute() in d:\Documents\Unreal Projects\VRShowRoom\UE4_Oculus\Engine\Source\Programs\AutomationTool\BuildCommand.cs:Zeile 37. MainFrameActions: Packaging (Windows (64-bit)): bei AutomationTool.Automation.Execute(List1 CommandsToExecute, CaselessDictionary`1 Commands) in d:\Documents\Unreal Projects\VRShowRoom\UE4_Oculus\Engine\Source\Programs\AutomationTool\Automation.cs:Zeile 380.
MainFrameActions: Packaging (Windows (64-bit)): bei AutomationTool.Automation.Process(String[] CommandLine) in d:\Documents\Unreal Projects\VRShowRoom\UE4_
MainFrameActions: Packaging (Windows (64-bit)): Oculus\Engine\Source\Programs\AutomationTool\Automation.cs:Zeile 352.
MainFrameActions: Packaging (Windows (64-bit)): bei AutomationTool.Program.MainProc(Object Param) in d:\Documents\Unreal Projects\VRShowRoom\UE4_Oculus\Engine\Source\Programs\AutomationTool\Program.cs:Zeile 172.
MainFrameActions: Packaging (Windows (64-bit)): bei AutomationTool.InternalUtils.RunSingleInstance(MainProc Main, Object Param) in d:\Documents\Unreal Projects\VRShowRoom\UE4_Oculus\Engine\Source\Programs\AutomationTool\Utils.cs:Zeile 716.
MainFrameActions: Packaging (Windows (64-bit)): bei AutomationTool.Program.Main() in d:\Documents\Unreal Projects\VRShowRoom\UE4_Oculus\Engine\Source\Programs\AutomationTool\Program.cs:Zeile 119.
MainFrameActions: Packaging (Windows (64-bit)): Program.Main: ERROR: An item with the same key has already been added
* (translated from German)
MainFrameActions: Packaging (Windows (64-bit)): ProcessManager.KillAll: Trying to kill 0 spawned processes.
MainFrameActions: Packaging (Windows (64-bit)): Program.Main: AutomationTool exiting with ExitCode=1
MainFrameActions: Packaging (Windows (64-bit)): Domain_ProcessExit
MainFrameActions: Packaging (Windows (64-bit)): ProcessManager.KillAll: Trying to kill 0 spawned processes.
MainFrameActions: Packaging (Windows (64-bit)): AutomationToolLauncher exiting with ExitCode=1
MainFrameActions: Packaging (Windows (64-bit)): copying UAT log files…
MainFrameActions: Packaging (Windows (64-bit)): RunUAT.bat ERROR: AutomationTool was unable to run successfully.
MainFrameActions: Packaging (Windows (64-bit)): BUILD FAILED*

And that’s it.

Out of pure desperation I tried to additionally build my game and the engine itself from VS again in ‘Shipping’ configuration, but that doesn’t change anything.Got still the same error.

It’s also not possible to cook the project (same error). How can I solve this? What is the ‘correct’ way to switch the engine build, which configuration should I choose (didn’t find anything about that in the documentation) for being able to package the project again?

Seriously, any advice? I have to get this done…

I now have stripped any source code out of the game (Blueprint-only), completely unloaded my game module - still no success.

Messing around with this since two days now, WHAT IS THE PROBLEM HERE?! :frowning:

Hey ,

Please try the following and let us know whether or not it works for you:

  • Go ahead and place your engine source code and project folders in separate folders
  • Build the engine, then go into Engine/Binaries/Win64 and run UnrealVersionSelector-Win64-Shipping.exe
  • Once you’ve done that, go to your project folder, right-click on .uproject and click ‘Switch Unreal Engine version’ and then select the Source build
  • Generate VS project files and proceed with packaging

Please let me know how this works for you, keep in mind that you may need to start from scratch depending on how your source build is ‘behaving’.

Thanks!

Hi ,

thanks for your answer. Your hint was definitly a step into the right direction. Seems that UE4 doesn’t like it if its placed in a project folder.

Here’s what I did:

  • Moved engine source from [project folder]/UE4_Oculus one level up into the same folder as [project folder]
  • Recreated UE4 project files
  • Opened solution in VS 2013 Professional
  • Built the engine with Unreal VS Quick Build → Win64 → Development Editor
  • Started UnrealVersionSelector-Win64-Shipping.exe
  • Configured uproject file to new engine build
  • Started UE4Editor.exe
  • Opened project
  • Started packaging in Win64-shipping configuration (‘development’ is grayed out for some reason)
  • (This started a new build process internally)
  • Process seemed to complete successfully (AutomationToolLauncher exiting with ExitCode=0)

These are the created files:


But I still can’t start the packaged game. There seems to be a reference to the uproject file outside the package:


So I rebuilt the engine once more in VS, this time in configuration ‘Win64/Shipping’ and started a new packaged process.

The Win64-EXE seems in place:


But unfortunately I still get the same error when trying to start it.

Moved engine source from [project folder]/UE4_Oculus one level up into the same folder as [project folder]

Since the engine source code was still within the project folder, I believe that may be the issue that you have. You should separate the engine source code and your project folder, completely. Have you tried that yet?

Hi ,

yes, this is exactly what I did. “Project” and “Engine” folders are separated (they are only in the same parent directory).

I believe there was an issue with Shipping builds and the stub .exe that’s in the root of your packaged build.

If you run the one in Win64 from the command line with the path to the descriptor, it should work:

Run cmd.exe
cd \VRShowRoom\Binaries\Win64
VRShowRoom-Win64-Shipping.exe …/…/…/VRShowRoom/VRShowRoom.uproject

You can put that into a .bat file in the root next to the .exe that’s there. Or, package Development, not Shipping. This is fixed in 4.9 I am pretty sure.

Josh

Hi Josh,

thanks for your answer.

Hmm, the strange thing is that this didn’t happen oin the binary version of the engine, only on the GitHub version.

So if I got you right I have to

  • Delete the original EXE
  • Bundle the uproject file with the packaged game
  • Call the binary of my project with the path to the uproject file as parameter

Ok, will try that (can’t test it until Friday)

BTW: I can’t create a development package, it’s grayed out for some reason.

Update: Doesn’t work.

  • Placed uproject file in same folder als VRShowRoom-Win64-Shipping.exe
  • Called “VRShowRoom-Win64-Shipping.exe VRShowRoom.uproject”
  • (Nothing happens. No error message but also no game window)



EDIT: If I just manually remove the ‘-Win64-Shipping.exe’ from /[project name]/Binaries/Win64/[projekt name]-Win64-Shipping.exe’ it works (but I can’t run the EXE in the root folder anymore)…!

EDIT 2: Another observation: If I include the removed, and completely unnecessary code module in the uproject file again (and restore the ‘source’ folder), it also works. Seems to be some linker error.

Don’t move the .exe. Run the exe with …/…/…/VRShowRoom/VRShowRoom.uproject as I originally stated. Did you try that?

I didn’t ever move one of the EXE files? And I tried to run this command, but it failes because there is no uproject file packaged.

Will try again after I updated to 4.9. Thank you anyway.

Let us know your results within 4.9, thank you!

Hi ,

Packaging worked indeed with 4.9 final (but I can’t use that version because of other problems currently).

I also tried again to run the custom version of 4.8.3 with …/…/…/VRShowRoom/VRShowRoom.uproject as you stated and I can confirm it works this way. Originally I was thinking that you refer to the EXE in the binary subfolder and that I have to really add the uproject file to the package.

Awesome ! I’m glad that this resolved your issue. Please let us know if you have any further questions!

Have a great day!

This is what I got. this is really ■■■■■■■ me off. Any suggestions???

Is your editor built from GitHub? It looks like Win64 Development wasn’t built in Visual Studio.

Let me know, thanks!

Necropost but possibly useful for someone because Unreal doesn’t provide good log on what causes the issue.

If you use custom Plugins, make sure your engine folder (extra check Marketplace folder) does not contain the same folder(s) as your project Plugin folder.

5 Likes

THIS fixed it for me. Thank you!