visual studio 2017 stuck building ue4

I think your problem is almost solved.
That error is easy to fix:

First go to your Windows Settings (I’m using Windows 10 so these instructions will be similar but not exactly the same for other versions of windows - I think it used to be called Control Panel)

Select “Apps”

Select “Visual Studio 2017 Community” (that’s the version I use)

Select “Modify”

It may want you to “update” which you should let it do.

When that is complete then you will be able to find and install .NETFramework,Version=v4.6.2