[SOLVED] Unable to rename tmp file in Visual Studio using 4.26

So I’ve been suffering from this issue in Visual Studio 2019 with every project I try with 4.26. I can code what I want, but when I build, I get errors like this for every cpp file:

Build started...
1>------ Skipped Build: Project: UE4, Configuration: BuiltWithUnrealBuildTool Win32 ------
1>Project not selected to build for this solution configuration 
2>------ Build started: Project: SubProject, Configuration: Development_Editor x64 ------
2>Using 'git status' to determine working set for adaptive non-unity build (E:\Users\Kjasi\Documents\Unreal Projects\SubProject 4.26).
2>Invalidating makefile for SubProjectEditor (StormSystem.cpp modified)
2>Building SubProjectEditor...
2>Using Visual Studio 2019 14.28.29335 toolchain (C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.28.29333) and Windows 10.0.18362.0 SDK (C:\Program Files (x86)\Windows Kits\10).
2>[Adaptive unity build] Excluded from SubProject unity file: StormDamageType.cpp, StormSystem.cpp
2>Building 5 actions with 12 processes...
2>  [1/5] StormSystem.cpp
2>EXEC : error : Unable to rename E:\Users\Kjasi\Documents\Unreal Projects\SubProject 4.26\Intermediate\Build\Win64\UE4Editor\Development\SubProject\StormSystem.cpp.txt.tmp to E:\Users\Kjasi\Documents\Unreal Projects\SubProject 4.26\Intermediate\Build\Win64\UE4Editor\Development\SubProject\StormSystem.cpp.txt
2>  [2/5] Module.SubProject.gen.cpp
2>EXEC : error : Unable to rename E:\Users\Kjasi\Documents\Unreal Projects\SubProject 4.26\Intermediate\Build\Win64\UE4Editor\Development\SubProject\Module.SubProject.gen.cpp.txt.tmp to E:\Users\Kjasi\Documents\Unreal Projects\SubProject 4.26\Intermediate\Build\Win64\UE4Editor\Development\SubProject\Module.SubProject.gen.cpp.txt
2>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.MakeFile.Targets(46,5): error MSB3073: The command ""E:\Unreal Engine\UE_4.26\Engine\Build\BatchFiles\Build.bat" SubProjectEditor Win64 Development -Project="E:\Users\Kjasi\Documents\Unreal Projects\SubProject 4.26\SubProject.uproject" -WaitMutex -FromMsBuild" exited with code 6.
2>Done building project "SubProject.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 1 skipped ==========

I don’t think it’s a permissions issue, as I don’t have this issue when compiling in 4.25, using the same folder setup.

The only work-around I’ve found is to go into E:\Users\Kjasi\Documents\Unreal Projects\SubProject 4.26\Intermediate\Build\Win64\UE4Editor\Development\SubProject\ folder and either manually delete the old .txt file, or rename the .tmp file to .txt.

Is there a better solution for this, preferably where I don’t have to manually delete or rename the file?

For future reference, if you’re having this issue where it can’t rename tmp files during compiling, add the Unreal Engine’s path as an exclusion to your Antivirus. It turns out Avast was seeing it as a “foreign” program and denied it permission to rename the file. With Unreal Engine added as an exclusion to my antivirus, it now works as expected.