Assumptions
- You're building the Unreal Engine from the github source.
- You're on Windows 10.
- Instructions from Visual Studio 2019 Community Edition are similar to those for VS2017.
Solution
The advice you got regarding /WX option is correct, but I don't think the *.target.cs file was the proper place to put it. I see hints that there is a variable to append additional command-line options in that file, but nothing solid. Also, since there are multiple targets that you can build, I figured the following is the safest way to go.
Steps
- Open the solution, UE4.sln.
- Right-click on the project UE4 > Properties.

- Go to Configuration Properties > NMake > Additional Options.
- Append /WX to the list of options already there.

- Press Okay and rerun your build.
Hope that solves your problem!
Additional Notes
The solution here configures msbuild to build the Unreal Engine binaries. Once you have those binaries build, the Unreal Build Tool (UBT) binary is used to build your UE-specific code (instead of msbuild). The configured UBT command treats warnings-as-errors by default.
References
MSVC Compiler Options > Warning Levels
Understanding Unreal Build Tool