Intermediate folder not included in project (UBT problem?)

I recently picked up some Unreal development after a pause, but it is not going well.
I updated to 4.20 but started to notice a lot of errors.
It turns out that my Visual Studio 2017 is unable to look in the Intermediate folder for the generated.h files.
The files are there, but it looks like the UBT does not add the folder to look in.
If I go to the Game Property Page and add the intermediate folder to the “NMake->Include Search Path” everything works again, but as soon as I re"generate the Visual Studio Project Files", the folder is missing again.

Does anyone know how to fix this? I reinstalled/verified Unreal and VS2017 but that does not help.

I am willing to reinstall all software if it would fix this problem, but so far nothing helped. Does anyone have an idea why these folders are not added by the UBT?

This is a bug introduced in 4.20. It’s already fixed and the fix will ship with the 4.20.2 hotfix.

@Sveitar: Thanks, but when I updated to the latest 4.20 branch from git (custom engine build), it still did not work.

Based in the latest code of 4.20 (19d7ee763c1809734e38b4a5ec31cf88d88b7f84), between 4.20.1 and 4.20.2, I needed to add the following to my MainGameEditor.Target.cs and MainGame.Target.cs

BuildEnvironment = TargetBuildEnvironment.Shared;

After that it works. Apparently it defaults to TargetBuildEnvironment.Unique and then the code still does not work (it will look in the MainGameEditor folder, but the generated includes are written in the UE4Editor folder.

Note, that this does not work for 4.20.1 as it still hasn’t been patched.
I do have a code workaround for 4.20.1 that seems to work, so let me know if you want it.

The problem is still happening in 4.21.2 and your solution still works.

Based on posts in this thread this is an issue when building UE4 from source, where BuildEnvironment gets set to Unique instead of Shared: UE4.20 is missing the IntelliSense IncludePath for the *.generated.h files - Platform & Builds - Epic Developer Community Forums

Supposedly installing UE4 from binary (the Epic Games Launcher) won’t have this problem. That seems like a bug to me. But at least I’ve finally found a workaround that works.