Problem with generating project files for source version of engine 4.27. Uses VS2022 instead of 2019

Hi.
I’m trying to build source version of UE4.27. I got Visual Studio 2019 and 2022 installed.
When I’m using GenerateProjectFiles.bat its generating 2022 (VS17) solution and I want to use VS16 - 2019 as it is recommended in documentation. Any idea how to do that? I started to change Engine\Build\BatchFiles\GenerateProjectFiles.bat where vswhere is calling -latest argument. I changed that for -version [16.0,17.0) it returns proper 2019 version but somehow it still uses 2022. So set explicitly

set MSBUILD_EXE=“C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe”

set MSBUILD_15_EXE=“C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe”

set MSBUILD_15_EXE_WITH_NUGET=“C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe”
but it still somehow uses 2022. I lost 4 hours with no success. Any ideas how to make it work without uninstalling 2022?
Thanks in advance!

SOLVED! You need to run .bat from cmd with -2019 parameter. Then is prompts that you can add code snippet to build configuration xml file.

3 Likes