Failure of building ue4 from source code: error MSB3644: The reference assemblies for .NETFramework,Version=v4.6.2 were not found

I followed the official guide and tried to build unreal engine from source code from github. However, when I tried to run the GenerateProjectFiles.bat, it throws the error:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targe ts(1217,5): error MSB3644: The reference assemblies for .NETFramework,Version=v4.6.2 were not found. To resolve this, i nstall the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can downloa d .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks [C:\Program Files\Unreal\UnrealEngine-4.25\En gine\Source\Programs\UnrealBuildTool\UnrealBuildTool.csproj]

The version of unreal is 4.25 and version of VS is community 19 ( I also tried community 2022, same)

I found two possible solutions and tried, but neither worked for me.

  1. I downloaded the .NET Framework 4.6.2 Develop Pack in https://docs.microsoft.com/en-us/dotnet/framework/install/guide-for-developers, and installed it. But nothing changed.
  2. I used the Visual Studio Installer → Modify → Individual Components to install .NET Framework 4.6.2 SDK & targeting pack.

And when I opened the UnrealBuildTool.csproj in VS, I found I can’t open it normally and absence of framework was told. I check the project property and found in Target Framework, only the core .net 2.0 3.0 3.5 can be chosen.

I doubt I made a mistake in env variable setting. I notice that System variable about .net is C:\Program Files\dotnet\, but in there the sdk folder only contains 5.0404 (C:\Program Files\dotnet\sdk\5.0.404)

Anyone has idea? :smiling_face_with_tear: I tried reinstall VS, nothing changed…

I have this issue, too. Tried grabbing 4.6.2 dev version and nada. Not even after reboot.

You need to clean the UnrealBuildTool folder ( \Engine\Source\Programs\UnrealBuildTool ) of any temporary data (bin/obj/.vs), I had a previous 5.0 build and it was interfering with a 4.27 switch