Skip to main content

Unreal Plugin Compile

· 2 min read

Tiny roboter on a piece of paper

Powershell script to recompile a plugin

This script will start the RunUAT.bat file filled with parameters to compile the plugin. Copy into a *.ps1 file, modify the parameter '$pathToEngine' and run in the director of the plugin.

You will need a working Visual Studio Installation to have the make file in your path.

Code - Compile plugin

Start the RunUAT.bat file filled with parameters to compile the plugin
######
# Variables: Set and execute script in the directory of your plugins .uplugin file
$pathToEngine = 'S:\Epic Games\UE_5.4' # path to your Unreal Engine installation

######
# Building variables
$build = 'build' # directory for files to be build - WILL BE DELETED BEFORE USAGE
$myPath = Get-Location
$plugin = $plugin + ".uplugin"
$plugin = Join-Path -Path $myPath -ChildPath $plugin

# Create RunUAT path
$path = Join-Path -Path $pathToEngine -ChildPath "Engine\Build\BatchFiles\RunUAT.bat"
Write-Host "Look for RunUAT at $path" -ForegroundColor Yellow

# Create tmp dir path
$tmpPath = Join-Path -Path $myPath -ChildPath $build
Write-Host "Build path is $tmpPath" -ForegroundColor Yellow

# build argument list
$argumentList = "BuildPlugin -plugin=" + $plugin + " -package=" + $tmpPath


# Deleting and recreating build folder
Write-Host "Will store build in $myPath\$inventory" -ForegroundColor Yellow
Remove-Item $build -Recurse -Force
New-Item -ItemType Directory -Path $build

##########################
# Start build process
Get-ChildItem -Path .\*.uplugin | ForEach-Object {
Write-Host "Processing plugin 'file $_'" -ForegroundColor Yellow
$pinfo = New-Object System.Diagnostics.ProcessStartInfo
$pinfo.FileName = $path
$pinfo.RedirectStandardError = $true
$pinfo.RedirectStandardOutput = $false
$pinfo.UseShellExecute = $false
$pinfo.Arguments = $argumentList
$p = New-Object System.Diagnostics.Process
$p.StartInfo = $pinfo
$p.Start() | Out-Null
$p.WaitForExit()
$stderr = $p.StandardError.ReadToEnd()

# report result
if ($p.ExitCode -eq 0) {
$msg = "Plugin compilation executed successfully - new version is stored in `n" + $tmpPath
Write-Host $msg -ForegroundColor Green
} else {
$msg = "Failed to compile plugin - error code: " + $p.ExitCode
Write-Host $msg -ForegroundColor Red
}
}