Support multiple EngineVersions

This commit is contained in:
Steve Streeting 2023-06-14 15:29:44 +01:00
parent 5202e2e63b
commit f21dff2084
4 changed files with 90 additions and 58 deletions

View File

@ -32,9 +32,33 @@ in the root of your plugin, next to the .uplugin file. The options are:
```json ```json
{ {
"OutputDir": "C:\\Users\\Steve\\MarketplaceBuilds", "OutputDir": "C:\\Users\\Steve\\MarketplaceBuilds",
"PluginFile": "OptionalPluginFilenameWillDetectInDirOtherwise.uplugin" "PluginFile": "OptionalPluginFilenameWillDetectInDirOtherwise.uplugin",
"EngineVersions":
[
"5.0.0",
"5.1.0",
"5.2.0"
]
} }
`OutputDir` and `EngineVersions` are required.
## Engine Versions
When submitting code plugins to the Marketplace, you're only allowed to include
a single supported `EngineVersion` in each version you upload. Even though you
don't submit built binaries to the Marketplace, the publisher portal requires
that the .uplugin has a single `EngineVersion` entry.
Therefore to support multiple engine versions, you have to upload several essentially
identical source archives, with each one having a different `EngineVersion` specified
in the .uplugin.
This script helps you do that; for each entry in `EngineVersions` in the `pluginconfig.json`,
a separate zip archive is generated, with the correct version set in the .uplugin.
> It seems you should always use ".0" as the 3rd version digit.
## Excluding Files ## Excluding Files
By default, the plugin packaging process automatically excludes common By default, the plugin packaging process automatically excludes common

View File

@ -2,6 +2,8 @@
class PluginConfig { class PluginConfig {
[string]$OutputDir [string]$OutputDir
[string]$PluginFile
[array]$EngineVersions
PluginConfig([PSCustomObject]$obj) { PluginConfig([PSCustomObject]$obj) {
# Construct from JSON object # Construct from JSON object

View File

@ -1,7 +1,14 @@
{ {
"OutputDir": "/Path/To/Output/Parent/Dir", "OutputDir": "/Path/To/Output/Parent/Dir",
"PluginFile": "OptionalPluginFilenameWillDetectInDirOtherwise.uplugin" "PluginFile": "OptionalPluginFilenameWillDetectInDirOtherwise.uplugin",
"EngineVersions":
[
"5.0",
"5.1",
"5.2"
]
} }

View File

@ -124,11 +124,18 @@ try {
} }
$proj = Read-Uproject $pluginfile $proj = Read-Uproject $pluginfile
$pluginName = (Get-Item $pluginfile).Basename $pluginName = (Get-Item $pluginfile).Basename
$saveuplugin = $false
# Default to latest engine if not specified
if (-not $config.EngineVersions -or $config.EngineVersions.Length -eq 0) {
Write-Output "Warning: EngineVersions missing from pluginconfig.json, assuming latest only"
$config.EngineVersions = [System.Collections.ArrayList]@()
$config.EngineVersions.add($proj.EngineVersion) > $null
}
Write-Output "" Write-Output ""
Write-Output "Plugin File : $pluginfile" Write-Output "Plugin File : $pluginfile"
Write-Output "Output Folder : $($config.OutputDir)" Write-Output "Output Folder : $($config.OutputDir)"
Write-Output "Engine Versions : $($config.EngineVersions -join ", ")"
Write-Output "" Write-Output ""
if (([bool]$major + [bool]$minor + [bool]$patch + [bool]$hotfix) -eq 0) { if (([bool]$major + [bool]$minor + [bool]$patch + [bool]$hotfix) -eq 0) {
@ -141,7 +148,6 @@ try {
$versionNumber = Get-NextPluginVersion -current:$versionNumber -major:$major -minor:$minor -patch:$patch -hotfix:$hotfix $versionNumber = Get-NextPluginVersion -current:$versionNumber -major:$major -minor:$minor -patch:$patch -hotfix:$hotfix
# Save incremented version back to uplugin object (will be saved later) # Save incremented version back to uplugin object (will be saved later)
$proj.VersionName = $versionNumber $proj.VersionName = $versionNumber
$saveuplugin = $true
} }
catch { catch {
Write-Output $_.Exception.Message Write-Output $_.Exception.Message
@ -169,85 +175,78 @@ try {
if (-not $proj.Installed) { if (-not $proj.Installed) {
# Need to set the installed=true for marketplace # Need to set the installed=true for marketplace
$proj.Installed = $true $proj.Installed = $true
$saveuplugin = $true
$resetinstalled = $true $resetinstalled = $true
} }
# Marketplace requires you to submit one package per EngineVersion for code plugins
# Pretty dumb since the only diff is the EngineVersion in .uplugin but sure
$oldEngineVer = $proj.EngineVersion
foreach ($EngineVer in $config.EngineVersions) {
Write-Output "Packaging for Engine Version $EngineVer"
$proj.EngineVersion = $EngineVer
if ($saveuplugin) {
$newjson = ($proj | ConvertTo-Json -depth 100) $newjson = ($proj | ConvertTo-Json -depth 100)
if ($dryrun) { if (-not $dryrun) {
Write-Output ""
Write-Output "Would have updated .uproject to:"
Write-Output $newjson
Write-Output ""
} else {
Write-Output "Writing updates to .uproject" Write-Output "Writing updates to .uproject"
$newjson | Out-File $pluginfile $newjson | Out-File $pluginfile
} }
} # Zip parent of the uplugin folder
$zipsrc = (Get-Item $pluginfile).Directory.FullName
$zipdst = Join-Path $config.OutputDir "$($pluginName)_v$($versionNumber)_UE$($EngineVer).zip"
$excludefilename = "packageexclusions.txt"
$excludefile = Join-Path $zipsrc $excludefilename
# Zip parent of the uplugin folder New-Item -ItemType Directory -Path $config.OutputDir -Force > $null
$zipsrc = (Get-Item $pluginfile).Directory.FullName Write-Output "Compressing to $zipdst"
$zipdst = Join-Path $config.OutputDir "$($pluginName)_$($versionNumber).zip"
$excludefilename = "packageexclusions.txt"
$excludefile = Join-Path $zipsrc $excludefilename
New-Item -ItemType Directory -Path $config.OutputDir -Force > $null $argList = [System.Collections.ArrayList]@()
Write-Output "Compressing to $zipdst" $argList.Add("a") > $null
$argList.Add($zipdst) > $null
# Standard exclusions
$argList.Add("-x!$pluginName\.git\") > $null
$argList.Add("-x!$pluginName\.git*") > $null
$argList.Add("-x!$pluginName\Binaries\") > $null
$argList.Add("-x!$pluginName\Intermediate\") > $null
$argList.Add("-x!$pluginName\Saved\") > $null
$argList.Add("-x!$pluginName\pluginconfig.json") > $null
$argList = [System.Collections.ArrayList]@() if (Test-Path $excludefile) {
$argList.Add("a") > $null $argList.Add("-x@`"$excludefile`"") > $null
$argList.Add($zipdst) > $null
# Standard exclusions
$argList.Add("-x!$pluginName\.git\") > $null
$argList.Add("-x!$pluginName\.git*") > $null
$argList.Add("-x!$pluginName\Binaries\") > $null
$argList.Add("-x!$pluginName\Intermediate\") > $null
$argList.Add("-x!$pluginName\Saved\") > $null
$argList.Add("-x!$pluginName\pluginconfig.json") > $null
if (Test-Path $excludefile) {
$argList.Add("-x@`"$excludefile`"") > $null
$argList.Add("-x!$pluginName\$excludefilename") > $null $argList.Add("-x!$pluginName\$excludefilename") > $null
} }
$argList.Add($zipsrc) > $null $argList.Add($zipsrc) > $null
if ($dryrun) { if ($dryrun) {
Write-Output "" Write-Output ""
Write-Output "Would have run:" Write-Output "Would have run:"
Write-Output "> 7z.exe $($argList -join " ")" Write-Output "> 7z.exe $($argList -join " ")"
Write-Output "" Write-Output ""
} else {
$proc = Start-Process "7z.exe" $argList -Wait -PassThru -NoNewWindow
if ($proc.ExitCode -ne 0) {
throw "7-Zip failed!"
}
} else {
$proc = Start-Process "7z.exe" $argList -Wait -PassThru -NoNewWindow
if ($proc.ExitCode -ne 0) {
throw "7-Zip failed!"
} }
} }
# Reset the installed flag back to how it was, for convenience
# Reset the uplugin
# Otherwise UE keeps prompting to update project files when using it as source # Otherwise UE keeps prompting to update project files when using it as source
if ($resetinstalled) { if ($resetinstalled) {
$proj.Installed = $false $proj.Installed = $false
$newjson = ($proj | ConvertTo-Json -depth 100)
if ($dryrun) {
Write-Output ""
Write-Output "Would have updated .uproject to:"
Write-Output $newjson
Write-Output ""
} else {
Write-Output "Writing updates to .uproject"
$newjson | Out-File $pluginfile
}
} }
$proj.EngineVersion = $oldEngineVer
if (-not $dryrun) {
$newjson = ($proj | ConvertTo-Json -depth 100)
Write-Output "Resetting .uproject"
$newjson | Out-File $pluginfile
}
if ($browse -and -not $dryrun) { if ($browse -and -not $dryrun) {