Last active
November 28, 2025 19:36
-
-
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 | |
| :: Define Colors | |
| :DefineColors | |
| for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do ( | |
| set "ESC=%%b" | |
| ) | |
| 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%" | |
| :: 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%" | |
| 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:}=!" | |
| ) | |
| :: 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) | |
| if not defined EngineDir ( | |
| if exist "%ProjectDir%\..\Engine\Binaries" set "EngineDir=%ProjectDir%\..\Engine" | |
| ) | |
| 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 | |
| popd | |
| pause | |
| exit /b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment