Download

Can't build UE5 from source: can't find TargetMetadata.dat

I downloaded the code from Github, switched to branch 5.0, and

.\Setup.bat
.\GenerateProjectFile.bat -2022

Then build in Visual Studio 2022.

I got these error:

Severity	Code	Description	Project	File	Line	Suppression State
Error		Unhandled exception: System.IO.FileNotFoundException: Could not find file 'C:\Users\rainc\github\UnrealEngine\Engine\Intermediate\Build\Win64\UnrealHeaderTool\Development\TargetMetadata.dat'.	UE5	C:\Users\rainc\github\UnrealEngine\Engine\Intermediate\ProjectFiles\EXEC	1	
Severity	Code	Description	Project	File	Line	Suppression State
Error	MSB3073	The command "..\..\Build\BatchFiles\Build.bat -Target="UnrealEditor Win64 Debug" -Target="ShaderCompileWorker Win64 Development -Quiet" -WaitMutex -FromMsBuild -2022" exited with code 6.	UE5	C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.MakeFile.Targets	44	

I tried Visual Studio 2019. Same issue:

Severity	Code	Description	Project	File	Line	Suppression State
Error		Unhandled exception: System.IO.FileNotFoundException: Could not find file 'C:\Users\rainc\github\UnrealEngine\Engine\Intermediate\Build\Win64\UnrealHeaderTool\Development\TargetMetadata.dat'.	UE5	C:\Users\rainc\github\UnrealEngine\Engine\Intermediate\ProjectFiles\EXEC	1	
Severity	Code	Description	Project	File	Line	Suppression State
Error	MSB3073	The command "..\..\Build\BatchFiles\Build.bat -Target="UnrealEditor Win64 Debug" -Target="ShaderCompileWorker Win64 Development -Quiet" -WaitMutex -FromMsBuild -2019" exited with code 6.	UE5	C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.MakeFile.Targets	45	

I ran the build.dat outside of VS:

Building 1 action with 1 process...
[1/1] UnrealBuildTool UnrealHeaderTool.target
ERROR: Unhandled exception: System.IO.FileNotFoundException: Could not find file 'C:\Users\rainc\github\UnrealEngine\Engine\Intermediate\Build\Win64\UnrealHeaderTool\Development\TargetMetadata.dat'.
       File name: 'C:\Users\rainc\github\UnrealEngine\Engine\Intermediate\Build\Win64\UnrealHeaderTool\Development\TargetMetadata.dat'
          at System.IO.FileStream.ValidateFileHandle(SafeFileHandle fileHandle)
          at System.IO.FileStream.CreateFileOpenHandle(FileMode mode, FileShare share, FileOptions options)
          at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
          at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access)
          at EpicGames.Core.BinaryFormatterUtils.Load[T](FileReference Location) in C:\Users\rainc\github\UnrealEngine\Engine\Source\Programs\Shared\EpicGames.Core\BinaryFormatterUtils.cs:line 20
          at UnrealBuildTool.WriteMetadataMode.ExecuteInternal(CommandLineArguments Arguments) in C:\Users\rainc\github\UnrealEngine\Engine\Source\Programs\UnrealBuildTool\Modes\WriteMetadataMode.cs:line 106
          at UnrealBuildTool.WriteMetadataMode.Execute(CommandLineArguments Arguments) in C:\Users\rainc\github\UnrealEngine\Engine\Source\Programs\UnrealBuildTool\Modes\WriteMetadataMode.cs:line 94
          at UnrealBuildTool.UnrealBuildTool.Main(String[] ArgumentsArray) in C:\Users\rainc\github\UnrealEngine\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.cs:line 593

So I believe the \TargetMetadata.dat is causing problems. How to fix it?

Please help!

It seems that the reference to TargetMetaData.dat was introduced by this commit: UBT: Fix engine failing to build on startup when a project module is … · EpicGames/UnrealEngine@104cf9d (github.com)

I’ll try to build its parent d2a825 and see if the problem is gone.

EDIT: d2a825 built successfully.

If you pull latest 5.0 branch it is fixed there now.

I think it was done by 905b2f0b

1 Like