From f3fab64c0c11854b1ae41f187cbca24ce3bb0dea Mon Sep 17 00:00:00 2001 From: Steve Streeting Date: Thu, 28 Sep 2023 14:35:09 +0100 Subject: [PATCH] Get-UE-Version can now determine version from source builds --- inc/uproject.ps1 | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/inc/uproject.ps1 b/inc/uproject.ps1 index 4a7086c..d7ca8a7 100644 --- a/inc/uproject.ps1 +++ b/inc/uproject.ps1 @@ -52,10 +52,20 @@ function Get-UE-Version { ) if ($uproject.EngineAssociation) { - return $uproject.EngineAssociation + $assoc = $uproject.EngineAssociation } else { # Plugin - return $uproject.EngineVersion + $assoc = $uproject.EngineVersion + } + + # If this is a GUID "{A1234786-..}" then it's a source build, we need to resolve it via registry + if ($assoc.StartsWith("{")) { + # Look up the source dir from registry setting + $srcdir = Get-ItemPropertyValue 'Registry::HKEY_CURRENT_USER\Software\Epic Games\Unreal Engine\Builds' -Name $assoc + # In source build, read Build.version JSON + $buildverfile = Join-Path $srcdir "Engine/Build/Build.version" + $buildjson = (Get-Content $buildverfile) | ConvertFrom-Json + return "$($buildjson.MajorVersion).$($buildjson.MinorVersion)" } }