Cannot generate project files after adding C++ to a blueprint project: Error while enumerating Visual Studio toolchains

I have installed binary 5.1 version from launcher. Created a blueprint project and it runs fine. I’ve added a C++ file and it failed to generate project files, and it keeps failing for some reason. I cannot even get the sln file… nothing. It fails from the very start.

I’ve switched from vs2019 to VS2022 and installed all workloads and components as stated in the documentation.

It keeps throwing this error:

Discovering modules, targets and source code for project...
Found Visual Studio installation: C:\Program Files\Microsoft Visual Studio\2022\Community (Product=Microsoft.VisualStudio.Product.Community, Version=17.4.33205.214)
Error while enumerating Visual Studio toolchains
COMException: Error HRESULT E_FAIL has been returned from a call to a COM component.
   at Microsoft.VisualStudio.Setup.Configuration.ISetupInstance2.GetState()
   at UnrealBuildTool.MicrosoftPlatformSDK.FindVisualStudioInstallations(ILogger Logger) in D:\build\++UE5\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\Platform\Windows\MicrosoftPlatformSDK.cs:line 780Wrapped by BuildException: Error while enumerating Visual Studio toolchains
   at UnrealBuildTool.MicrosoftPlatformSDK.FindVisualStudioInstallations(ILogger Logger) in D:\build\++UE5\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\Platform\Windows\MicrosoftPlatformSDK.cs:line 823
   at UnrealBuildTool.VCProjectFileGenerator.SetupSupportedPlatformsAndConfigurations(Boolean IncludeAllPlatforms, ILogger Logger, String& SupportedPlatformNames) in D:\build\++UE5\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\ProjectFiles\VisualStudio\VCProjectFileGenerator.cs:line 294
   at UnrealBuildTool.ProjectFileGenerator.GenerateProjectFiles(PlatformProjectGeneratorCollection PlatformProjectGenerators, String[] Arguments, ILogger Logger) in D:\build\++UE5\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\ProjectFiles\ProjectFileGenerator.cs:line 858
   at UnrealBuildTool.GenerateProjectFilesMode.Execute(CommandLineArguments Arguments, ILogger Logger) in D:\build\++UE5\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\Modes\GenerateProjectFilesMode.cs:line 233
   at UnrealBuildTool.UnrealBuildTool.Main(String[] ArgumentsArray) in D:\build\++UE5\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.cs:line 648
WriteFileIfChanged() wrote 0 changed files of 0 requested writes.

My DVDRom was on D so I thought that maybe it is failing because of it so I moved it further down. D is now free but it still fails.

I’ve been struggling with this the whole day and I’m out of ideas.
What am I doing wrong?

PS
Version 4.26 works fine :no_mouth:

1 Like

I have reinstalled everything from scratch, Visual Studio and Unreal Engine and still no luck. I keep getting the same error when I try to generate the project files.
Please help, at this point, I’m desperate.

1 Like

Experiencing the same issue today out of the blue, everything worked till yesterday. Did you find a solution?