Last active
February 16, 2026 13:37
-
-
Save Solessfir/8ed3df75b51214661131bc13dc9d05ee to your computer and use it in GitHub Desktop.
Unreal Engine Derived Data Cache Builder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| :: Copyright (c) Solessfir under MIT license | |
| :: Builds the Derived Data Cache (DDC) for an Unreal Engine project | |
| :: Place this file in your project's root directory and run it | |
| @echo off | |
| setlocal EnableDelayedExpansion | |
| title Build Derived Data Cache | |
| :: Enable ANSI color support | |
| reg add HKCU\Console /v VirtualTerminalLevel /t REG_DWORD /d 1 /f >nul 2>&1 | |
| :: Define Colors | |
| for /f "delims=" %%a in ('powershell -NoProfile -Command "[char]27"') do set "ESC=%%a" | |
| set "Colors_Red=!ESC![91m" | |
| set "Colors_Green=!ESC![92m" | |
| set "Colors_White=!ESC![97m" | |
| set "Colors_Reset=!ESC![0m" | |
| :: Configuration | |
| set "RootDirectory=%~dp0" | |
| set "RootDirectory=%RootDirectory:~0,-1%" | |
| set "PushdDone=0" | |
| :: 1. Locate Project | |
| if exist "%RootDirectory%\*.uproject" ( | |
| set "ProjectDir=%RootDirectory%" | |
| ) else if exist "%RootDirectory%\..\*.uproject" ( | |
| set "ProjectDir=%RootDirectory%\.." | |
| ) else ( | |
| echo !Colors_Red!Error: No .uproject file found.!Colors_Reset! | |
| goto :ExitWithPause | |
| ) | |
| pushd "%ProjectDir%" | |
| set "PushdDone=1" | |
| for %%i in ("*.uproject") do set "UprojectFile=%%~fi" & set "ProjectName=%%~ni" | |
| :: 2. Extract Engine Association | |
| set "RawVersion=" | |
| for /f "tokens=2 delims=:" %%a in ('findstr /i "EngineAssociation" "%UprojectFile%"') do set "RawVersion=%%a" | |
| :: Clean string (remove quotes, spaces, braces, and commas) | |
| if defined RawVersion ( | |
| set "RawVersion=!RawVersion:"=!" | |
| set "RawVersion=!RawVersion:,=!" | |
| set "RawVersion=!RawVersion: =!" | |
| set "RawVersion=!RawVersion:{=!" | |
| set "RawVersion=!RawVersion:}=!" | |
| ) else ( | |
| echo !Colors_Red!Error: 'EngineAssociation' not found in .uproject file.!Colors_Reset! | |
| goto :ExitWithPause | |
| ) | |
| :: 3. Determine Engine Path | |
| set "EngineDir=" | |
| :: A. Check Standard Installation (HKLM) | |
| reg query "HKLM\SOFTWARE\EpicGames\Unreal Engine\%RawVersion%" /v "InstalledDirectory" >nul 2>&1 | |
| if !errorlevel! equ 0 ( | |
| for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\EpicGames\Unreal Engine\%RawVersion%" /v "InstalledDirectory"') do set "EngineDir=%%b" | |
| ) | |
| :: B. Check Custom/Source Build Registration (HKCU - matches GUIDs) | |
| if not defined EngineDir ( | |
| reg query "HKCU\Software\Epic Games\Unreal Engine\Builds" /v "{%RawVersion%}" >nul 2>&1 | |
| if !errorlevel! equ 0 ( | |
| for /f "skip=2 tokens=2*" %%a in ('reg query "HKCU\Software\Epic Games\Unreal Engine\Builds" /v "{%RawVersion%}"') do set "EngineDir=%%b" | |
| ) | |
| ) | |
| :: C. Check Relative Path (Assuming Project is inside/next to Engine root) | |
| :: EngineDir must be set to the engine root so that %EngineDir%\Engine\Binaries\... | |
| :: resolves correctly — consistent with what the registry returns in cases A and B. | |
| if not defined EngineDir ( | |
| if exist "%ProjectDir%\..\Engine\Binaries" set "EngineDir=%ProjectDir%\.." | |
| ) | |
| if not defined EngineDir ( | |
| echo !Colors_Red!Error: Could not locate Unreal Engine installation for: %RawVersion%!Colors_Reset! | |
| goto :ExitWithPause | |
| ) | |
| :: 4. Locate Editor CMD Executable (UE5 or UE4) | |
| set "EditorCmd=%EngineDir%\Engine\Binaries\Win64\UnrealEditor-Cmd.exe" | |
| if not exist "!EditorCmd!" ( | |
| set "EditorCmd=%EngineDir%\Engine\Binaries\Win64\UE4Editor-Cmd.exe" | |
| ) | |
| if not exist "!EditorCmd!" ( | |
| echo !Colors_Red!Error: Editor executable not found at:!Colors_Reset! | |
| echo %EngineDir%\Engine\Binaries\Win64\ | |
| goto :ExitWithPause | |
| ) | |
| :: 5. Execute DDC Build | |
| cls | |
| echo !Colors_Green!:: Building Derived Data Cache ::!Colors_Reset! | |
| echo Project: !Colors_White!%ProjectName%!Colors_Reset! | |
| echo Engine: !Colors_White!%RawVersion%!Colors_Reset! | |
| echo Path: !Colors_White!!EditorCmd!!Colors_Reset! | |
| echo: | |
| call "!EditorCmd!" "%UprojectFile%" -run=DerivedDataCache -fill -DDC=CreatePak -ProjectOnly | |
| echo: | |
| if !errorlevel! neq 0 ( | |
| echo !Colors_Red!DDC Build Failed. Check the log above.!Colors_Reset! | |
| ) else ( | |
| echo !Colors_Green!DDC Build Completed Successfully.!Colors_Reset! | |
| ) | |
| :ExitWithPause | |
| if "%PushdDone%"=="1" popd | |
| pause | |
| exit /b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment