[Bug Report] GenerateProjectFiles doesn't work with only Preview toolchains available

Engine\Platforms\Hololens\Source\Programs\UnrealBuildTool\HoloLensProjectGenerator.cs line 87:

DirectoryReference? PlatformWinMDLocation = HoloLensPlatform.GetCppCXMetadataLocation(Compiler, "Latest", WindowsArchitecture.x64, Logger);

Hardcodes "Latest" as the CompilerVersion, which it wont find any if only preview toolchains are available, causing GenerateProjectFiles to fail.

I’m using:
UE5.1 built from source, release branch retrieved January 17, 2023.
Visual Studio Community 2022 Preview 17.5.0 Preview 2.0.
All of the MSVC v143 x86/x64 toolchains available in the Visual Studio Installer install preview toolchains, so this was preventing me from generating project files altogether.

Reproduce:

  1. Installed Visual Studio Community 2022 Preview 17.5.0 Preview 2.0 (no other versions installed)
  2. Cloned release branch of UnrealEngine
  3. Ran Setup.bat
  4. In both BuildConfiguration.xml, set ProjectFileGenerator.Format to VisualStudio2022 and WindowsPlatform.CompilerVersion to Preview
  5. Run GenerateProjectFiles.bat (fails)
  6. Tried installing the other relevant toolchains, still fails.

I have something like your problem