diff --git a/doc/Package.md b/doc/Package.md index b31bc22..2145988 100644 --- a/doc/Package.md +++ b/doc/Package.md @@ -102,6 +102,16 @@ The destination of the package operation is generated from a combination of: Therefore if you're building variant "PublicSteamWin64" at version 1.1.2.0, the package output will be in `$OutputDir/1.1.2.0/PublicSteamWin64/` +### Optionally Rename EXE + +Sometimes you want your packaged EXE to be called something other than your main +target game module; unfortunately UE doesn't allow you to change it in the project +settings (without renaming your module, which is very inconvenient); but simply +renaming it after building works fine, and means you can present a more pleasing +EXE name in your build. + +Set `RenameExe` to the name you want your EXE to have, without the `.exe` extension. + ### 9. Optionally Zip Packaged Build If you've enabled the `Zip` option for a given variant in [packageconfig.json](PackageConfig.md), diff --git a/inc/packageconfig.ps1 b/inc/packageconfig.ps1 index 3502f01..2ee1861 100644 --- a/inc/packageconfig.ps1 +++ b/inc/packageconfig.ps1 @@ -54,6 +54,8 @@ class PackageConfig { # Will be structured $OutputDir/$version/$variant # If relative, will be considered relative to source folder [string]$OutputDir + # Optional name to rename the output EXE to + [string]$RenameExe # Folder to place zipped releases (named $target_$platform_$variant_$version.zip) # If relative, will be considered relative to source folder [string]$ZipDir diff --git a/packageconfig_template.json b/packageconfig_template.json index c15c674..c90aef4 100644 --- a/packageconfig_template.json +++ b/packageconfig_template.json @@ -5,6 +5,7 @@ "ProjectFile": "OptionalProjectFilenameWillDetectInDirOtherwise.uproject", "Target": "GameTargetName", + "RenameExe": "NewExeNameWithNoExtension", "CookAllMaps": true, "MapsIncluded": [ "IfCookAllMapsIsFalse", diff --git a/ue-package.ps1 b/ue-package.ps1 index 8952c2b..e9fbf21 100644 --- a/ue-package.ps1 +++ b/ue-package.ps1 @@ -272,6 +272,25 @@ try { } + if ($config.RenameExe.Length -gt 0) { + if ($dryrun) { + Write-Output "Would have renamed EXE from $($config.Target) to $($config.RenameExe)" + } else { + # Rename the executable + $subdirs = @(Get-ChildItem $outdir) + $subdirs | ForEach-Object { + $renameExeSuffix = "" + if ($var.Platform -like "Win*") { + $renameExeSuffix = ".exe" + } + $exeSrcName = Join-Path $_.FullName "$($config.Target)$renameExeSuffix" + $exeDestName = Join-Path $_.FullName "$($config.RenameExe)$renameExeSuffix" + Move-Item $exeSrcName $exeDestName -Force + } + } + + } + if ($var.Zip) { if ($dryrun) { Write-Output "Would have compressed $outdir to $(Join-Path $config.ZipDir "$($config.Target)_$($versionNumber)_$($var.Name).zip")"