This is a pretty niche answer, but I will provide it here in case it helps anyone. I had both v140 (2015) and v141 (2017) build tools installed for Visual Studio. The reason was that I sometimes had to use v140 build tools for stuff such as setting up amazon gamelift. However, I wanted to continue building my Unreal projects using v141 so I deleted the v140 tools. What I forgot to do was delete the VCTargetsPath
variable that I set to the location of the v140 tools in my environment variables.
After doing so, I had to do some other things such as re-generating the visual studio files as well as cleaning the project before building again. Note that you may still have to right-click the project files and select “Reload Project”.