Unable to Generate VS Code Project Files

Alright, it took me a bit and the other person I’m working on the project with apparently had this issue as well a while ago.

Looks like there’s essentially a bug in the 5.2 engine VSCodeProjectFileGenerator.cs

in my case installed at
C:\Program Files\Epic Games\UE_5.2\Engine\Source\Programs\UnrealBuildTool\ProjectFiles\VisualStudioCode\VSCodeProjectFileGenerator.cs

Down around line 1554 it checks a reference to Projects[0].BaseDir which i’m assuming has no entires, thus the index out of range error as this is the first 5.2 project i’m setting up on this computer. So at least a quick fix that seems to be working is returning if Projects is null or 0

// Line 1552 Code I added to fix the issue
if (Projects == null || Projects.Count == 0) {
	return;
}

With this the generator runs succesfully with no errors, though do note I had to open the UnrealBuildTool.sln and rebuild it before it took effect (rebuilt by just opening it with Visual Studios 2022 and selecting build, upon success i could then just right click on the .uproject file for my project and running “generate visual studios project files”
C:\Program Files\Epic Games\UE_5.2\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.sln

So this all happened because I had to reformat my computer, but originally I had a few other 5.2 projects from some tutorials I had worked through that just used blueprints, so no coding or opening in VS Code before. I’m guessing because they existed the Projects var had multiple other entries resulting in me not having a problem when I originally set this new project up.

So in theory if you don’t want to mess with engine code you could potentially make multiple 5.2 projects before the one you want to actually build?

Side note to the StaterContent.upack issue, so if I just delete it out of the 5.2 engine directory and load up the project there’s no error, but revalidating and getting the file back in will show the error again, so at least for now planning to just delete it and hopefully it won’t cause any issues