UnrealBuildTool Unable to open log file for writing because it is being used by another process

I keep getting

UnrealBuildTool : error : Unhandled exception: System.Exception: Unable to open log file for writing (UnrealEngine-dev-rendering\Engine\Programs\UnrealBuildTool\Log.txt) —> System.IO.IOException: The process cannot access the file ‘\UnrealEngine-dev-rendering\Engine\Programs\UnrealBuildTool\Log.txt’ because it is being used by another process.

But there is no other process using it besides the build itself ??

So I was able to get passed this by changing Maximum number of parallel project builds to 1 in Visual Studio (Menu> Tools > Options > Projects and solutions > Build and Run. )

Of course this is not the fastest, but it seems to resolve error which I assume is caused by race condition and simultaneous building

I hit this too. IMO the log file should include the VS project name in its name so that it’s unique.

Disabling parallel builds allowed the real error to come through:

[245/2741] Module.ContentBrowser.2_of_3.cpp
d:\epic games\source\dev-rendering\engine\source\editor\contentbrowser\private\sassetview.cpp(2031): fatal error C1001: An internal error has occurred in the compiler.
  (compiler file 'd:\agent\_work\1\s\src\vctools\compiler\utc\src\p2\main.c', line 187)
   To work around this problem, try simplifying or changing the program near the locations listed above.
  Please choose the Technical Support command on the Visual C++
   Help menu, or open the Technical Support help file for more information

The rest of them are basically the same thing.

I’m also running into this when building the entire UE4 solution from the latest github sources master branch. Has anyone here reported the issue to Epic yet?

I found the answer and had a moment of deja vu. You need to turn parallel builds down to 1 in VS. You can possibly get away with more but most likely not.

This will cause it to build slower, but it will actually work. Seems like a crazy thing to not have fixed in 22 versions of the engine though.

Oh, I had incorrectly skim read @OptimisticMonkey’s solution. When I read “Maximum number of parallel project builds” I stopped reading and assumed it was going to be setting MaxProcessorCount to 1 in BuildConfiguration.xml, which if was true would have pointed to a UE4 build bug. But this parallel build option in VS is a global setting, not per project. I didn’t even know such an option existed.

Although I can understand why this would mess up Unreal Build Tool, it would be nice if you got a warning about this (perhaps during VS project file generation), or if Epic said to set the value to 1 in the UE4 Visual Studio Setup Guide or github README. I’ll try this solution out and if it works for me, I’ll make a pull request on the README.

The weird thing is VS has nothing to do with the UE build, it just kicks off too many instances of UBT at once.