[4.7.3] UBT Fails to create any project files with C++

Sometime yesterday while working, I needed to remove a C++ class I had created. (Being new to Unreal, I was unsure how to do this) So I went ahead and just deleted the .cpp and .h files. After doing this, however, I was unable to recompile my project, even after replacing the files via git.

Because the project I was working in was a bit of a toy, I decided to just delete the project and create a new one, but I get an error from UBT saying ‘The file exists’

I saw this report saying something similar, but the error seemed different, I was unable to create a project following the steps posted.

I first deleted just my install of 4.7, but then uninstalled all Epic Games/Unreal software and re-installed in an attempt to fix.

My last attempt was to create a blueprint project and just ‘Add code to project’, but even that throws an error saying ‘Unable to generate project files’.

Below is the error I get when trying to create a new C++ project.

Failed to generate project files. Log output:
Running C:/Program Files/Epic Games/4.7/Engine/Binaries/DotNET/UnrealBuildTool.exe -projectfiles -project="C:/Users/Ben/code/ue4/BugTest/BugTest.uproject" -game -rocket -progress
Discovering modules, targets and source code for game...
UnrealBuildTool Exception: System.IO.IOException: The file exists.

   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.Path.InternalGetTempFileName(Boolean checkHost)
   at UnrealBuildTool.Utils.SetEnvironmentVariablesFromBatchFile(String BatchFileName)
   at UnrealBuildTool.VCEnvironment..ctor(CPPTargetPlatform InPlatform)
   at UnrealBuildTool.VCToolChain.GetVCIncludePaths(CPPTargetPlatform Platform)
   at UnrealBuildTool.VCProjectFile.WriteProjectFile(List`1 InPlatforms, List`1 InConfigurations)
   at UnrealBuildTool.ProjectFileGenerator.WriteProjectFiles()
   at UnrealBuildTool.ProjectFileGenerator.GenerateProjectFiles(String[] Arguments, Boolean& bSuccess)
   at UnrealBuildTool.UnrealBuildTool.GenerateProjectFiles(ProjectFileGenerator Generator, String[] Arguments)
   at UnrealBuildTool.UnrealBuildTool.Main(String[] Arguments)

If this is related to the known issue mentioned in the other thread, I’ll just try to downgrade to a lower version of UE until this is fixed, but if there are any cache directories I can delete that will allow me to fix this even temporarily, that would be awesome.

A little bit of extra context, I just cloned the repo from GitHub, to see if building from source would help, and Setup.bat threw the same error…

I managed to fix the error in Setup.bat by deleting my AppData/Local/Temp directory. I’m downloading a new copy of 4.7.3 to see if the issue is truly resolved.

The TL;DR solution was to delete ~\AppData\Local\Temp

I’ll go ahead and detail how I fixed this for myself in case it’s helpful for anyone at Epic, or in case anybody else runs into a similar problem.

I first deleted all the files I could possibly find related to Unreal, the launcher, UT, everything, and clone a copy of the GitHub repository, and when building that failed with the same error, I knew I had a problem related to my system.
So I opened up Setup.bat and realized that it was failing while executing GitDependencies.exe in .\Engine\Binaries\DotNET.
I downloaded ProcessMonitor and watched the process run until it crashed while trying to OpenWrite a file in the Temp directory.

I guess the real bug here might be in the use of System.IO.Path.InternalGetTempFileName (from the stacktrace above)