Summary
VSCodeProjectFileGenerator crashes with ArgumentOutOfRangeException for a project whose .uproject has no “Modules” entry
What Type of Bug are you experiencing?
Editor
Steps to Reproduce
- Take a project whose .uproject has no top-level “Modules” array (all its C++ comes from a plugin instead, a Marketplace/Fab plugin with native code). This means it also has no top-level Source folder. (Reproduced with the “Cropout” sample project + the AltTester plugin from the Marketplace.)
- Run GenerateProjectFiles.sh (Mac) with: -project=“<path-to-.uproject>” -game -vscode
- Generation proceeds through module discovery and indexing, then crashes during “Writing project files…”
For comparison: the same command against a project that DOES declare its own “Modules” entry (Epic’s “Project Titan” sample) succeeds normally on the same engine build.
Expected Result
Project files generate successfully, the same as for a project that declares its own Modules array. A project that gets all its C++ from a plugin, with no module of its own, is a normal setup and shouldn’t crash generation.
Observed Result
Generation crashes with an unhandled ArgumentOutOfRangeException right after “Writing project files… 50%”. Full output:
Unhandled exception: ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter ‘index’)
at UnrealBuildTool.VSCodeProjectFileGenerator.WriteWorkspaceIgnoreFile(List`1 Projects)
at UnrealBuildTool.VSCodeProjectFileGenerator.WritePrimaryProjectFile(ProjectFile UBTProject, PlatformProjectGeneratorCollection PlatformProjectGenerators, ILogger Logger)
at UnrealBuildTool.ProjectFileGenerator.WriteProjectFiles(PlatformProjectGeneratorCollection PlatformProjectGenerators, ILogger Logger)
at UnrealBuildTool.ProjectFileGenerator.GenerateProjectFiles(PlatformProjectGeneratorCollection PlatformProjectGenerators, String Arguments, ILogger Logger)
at UnrealBuildTool.GenerateProjectFilesMode.ExecuteAsync(CommandLineArguments Arguments, ILogger Logger)
at UnrealBuildTool.UnrealBuildTool.Main(String ArgumentsArray)
Result: Failed (OtherCompilationError)
Tried the same command on two different projects on the same unmodified UE 5.8 engine: the one without a Modules entry crashes every time, the one that has one (Project Titan) works every time.
Affects Versions
5.8
Platform(s)
Mac
For crash reports, include your callstack
at UnrealBuildTool.VSCodeProjectFileGenerator.WriteWorkspaceIgnoreFile(List`1 Projects)
at UnrealBuildTool.VSCodeProjectFileGenerator.WritePrimaryProjectFile(ProjectFile UBTProject, PlatformProjectGeneratorCollection PlatformProjectGenerators, ILogger Logger)
at UnrealBuildTool.ProjectFileGenerator.WriteProjectFiles(PlatformProjectGeneratorCollection PlatformProjectGenerators, ILogger Logger)
at UnrealBuildTool.ProjectFileGenerator.GenerateProjectFiles(PlatformProjectGeneratorCollection PlatformProjectGenerators, String Arguments, ILogger Logger)
at UnrealBuildTool.GenerateProjectFilesMode.ExecuteAsync(CommandLineArguments Arguments, ILogger Logger)
at UnrealBuildTool.UnrealBuildTool.Main(String ArgumentsArray)
Additional Notes
Line 1665 in VSCodeProjectFileGenerator.cs (UE 5.8):
DirectoryReference WorkspaceRoot = bForeignProject ? Projects[0].BaseDir : Unreal.RootDirectory;
Projects only has entries for targets the project itself owns. If the .uproject has no “Modules” array, there’s no project-owned target, just a stub target UBT makes up on the fly to build the plugin’s code, so Projects is empty and Projects[0] throws.
Fix:
DirectoryReference WorkspaceRoot = (bForeignProject && Projects.Count > 0) ? Projects[0].BaseDir : Unreal.RootDirectory;
Tested this on the project that was crashing and it generates fine now.