Add option to rename EXE after packaging

This commit is contained in:
Steve Streeting 2023-06-26 16:38:52 +01:00
parent 0ecdbec381
commit 6b6a72f5b2
4 changed files with 32 additions and 0 deletions

View File

@ -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 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/` 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 ### 9. Optionally Zip Packaged Build
If you've enabled the `Zip` option for a given variant in [packageconfig.json](PackageConfig.md), If you've enabled the `Zip` option for a given variant in [packageconfig.json](PackageConfig.md),

View File

@ -54,6 +54,8 @@ class PackageConfig {
# Will be structured $OutputDir/$version/$variant # Will be structured $OutputDir/$version/$variant
# If relative, will be considered relative to source folder # If relative, will be considered relative to source folder
[string]$OutputDir [string]$OutputDir
# Optional name to rename the output EXE to
[string]$RenameExe
# Folder to place zipped releases (named $target_$platform_$variant_$version.zip) # Folder to place zipped releases (named $target_$platform_$variant_$version.zip)
# If relative, will be considered relative to source folder # If relative, will be considered relative to source folder
[string]$ZipDir [string]$ZipDir

View File

@ -5,6 +5,7 @@
"ProjectFile": "OptionalProjectFilenameWillDetectInDirOtherwise.uproject", "ProjectFile": "OptionalProjectFilenameWillDetectInDirOtherwise.uproject",
"Target": "GameTargetName", "Target": "GameTargetName",
"RenameExe": "NewExeNameWithNoExtension",
"CookAllMaps": true, "CookAllMaps": true,
"MapsIncluded": [ "MapsIncluded": [
"IfCookAllMapsIsFalse", "IfCookAllMapsIsFalse",

View File

@ -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 ($var.Zip) {
if ($dryrun) { if ($dryrun) {
Write-Output "Would have compressed $outdir to $(Join-Path $config.ZipDir "$($config.Target)_$($versionNumber)_$($var.Name).zip")" Write-Output "Would have compressed $outdir to $(Join-Path $config.ZipDir "$($config.Target)_$($versionNumber)_$($var.Name).zip")"