-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.ps1
More file actions
198 lines (163 loc) · 7.86 KB
/
Copy pathbuild.ps1
File metadata and controls
198 lines (163 loc) · 7.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
#Requires -Version 5.1
<#
.SYNOPSIS
Builds PakEditor and assembles the full distributable output.
.PARAMETER Configuration
Build configuration: Debug or Release (default: Release)
.PARAMETER Version
Version tag for the output zip, e.g. "1.0-a2" (default: "1.0")
.PARAMETER NoPause
Skip the pause at the end (useful for CI)
.EXAMPLE
.\build.ps1
.\build.ps1 -Version 1.0-a2
.\build.ps1 -Configuration Debug -Version 1.0-a2
.\build.ps1 -Configuration Release -NoPause
#>
param(
[ValidateSet('Debug','Release')]
[string]$Configuration = 'Release',
[string]$Version = '',
[switch]$NoPause
)
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
if ($Configuration -eq 'Release' -and [string]::IsNullOrWhiteSpace($Version)) {
$input = Read-Host "Version tag for zip (e.g. 1.0-a2) [1.0]"
$Version = if ([string]::IsNullOrWhiteSpace($input)) { '1.0' } else { $input.Trim() }
}
$root = $PSScriptRoot
$out = Join-Path $root "publish\$($Configuration.ToLower())"
$fmodel = Join-Path $root "FModel\FModel"
function Copy-IfExists([string]$src, [string]$dst) {
if (Test-Path $src) {
$dir = Split-Path $dst -Parent
if ($dir -and !(Test-Path $dir)) { New-Item $dir -ItemType Directory -Force | Out-Null }
Copy-Item $src $dst -Force
Write-Host " copied $(Split-Path $src -Leaf)"
} else {
Write-Warning " MISSING $src"
}
}
# -------------------------------------------------------------------------
# Step 1 - Build
# -------------------------------------------------------------------------
Write-Host ""
Write-Host "================================================================" -ForegroundColor Cyan
Write-Host " PakEditor -- $Configuration build (v$Version)" -ForegroundColor Cyan
Write-Host "================================================================" -ForegroundColor Cyan
Write-Host ""
Write-Host "Step 1/5 Building ($Configuration)..." -ForegroundColor Yellow
Push-Location $fmodel
try {
if ($Configuration -eq 'Release') {
dotnet publish FModel.csproj `
-c Release -r win-x64 `
--self-contained true `
-p:PublishSingleFile=true `
-p:IncludeNativeLibrariesForSelfExtract=true `
-o $out
} else {
dotnet publish FModel.csproj `
-c Debug -r win-x64 `
--no-self-contained `
-o $out
}
if ($LASTEXITCODE -ne 0) { throw "dotnet publish failed (exit $LASTEXITCODE)" }
} finally {
Pop-Location
}
Write-Host " Build OK -> $out" -ForegroundColor Green
# -------------------------------------------------------------------------
# Step 2 - Bundle UAssetGUI (portable, v1.0.4+)
# -------------------------------------------------------------------------
Write-Host ""
Write-Host "Step 2/5 Bundling UAssetGUI..." -ForegroundColor Yellow
$uagSrc = Join-Path $root "UAssetGUI"
$uagDst = Join-Path $out "UAssetGUI"
New-Item $uagDst -ItemType Directory -Force | Out-Null
Copy-IfExists (Join-Path $uagSrc "UAssetGUI.exe") (Join-Path $uagDst "UAssetGUI.exe")
Copy-IfExists (Join-Path $uagSrc "LICENSE") (Join-Path $uagDst "LICENSE")
Copy-IfExists (Join-Path $uagSrc "NOTICE.md") (Join-Path $uagDst "NOTICE.md")
Copy-IfExists (Join-Path $uagSrc "README.md") (Join-Path $uagDst "README.md")
if (!(Test-Path (Join-Path $uagDst "UAssetGUI.exe"))) {
Write-Warning "UAssetGUI.exe missing. Download v1.0.4+ from https://github.com/atenfyr/UAssetGUI/releases and place it in UAssetGUI\"
}
# -------------------------------------------------------------------------
# Step 3 - Bundle retoc
# -------------------------------------------------------------------------
Write-Host ""
Write-Host "Step 3/5 Bundling retoc..." -ForegroundColor Yellow
$retocSrc = Join-Path $root "Retoc"
$retocDst = Join-Path $out "Retoc"
New-Item $retocDst -ItemType Directory -Force | Out-Null
Copy-IfExists (Join-Path $retocSrc "retoc.exe") (Join-Path $retocDst "retoc.exe")
Copy-IfExists (Join-Path $retocSrc "LICENSE") (Join-Path $retocDst "LICENSE")
Copy-IfExists (Join-Path $retocSrc "README.md") (Join-Path $retocDst "README.md")
# -------------------------------------------------------------------------
# Step 4 - Copy docs and licenses
# -------------------------------------------------------------------------
Write-Host ""
Write-Host "Step 4/5 Copying docs and licenses..." -ForegroundColor Yellow
Copy-IfExists (Join-Path $root "README.md") (Join-Path $out "README.md")
Copy-IfExists (Join-Path $root "LICENSE") (Join-Path $out "LICENSE")
Copy-IfExists (Join-Path $root "NOTICE") (Join-Path $out "NOTICE")
$licDst = Join-Path $out "licenses"
New-Item $licDst -ItemType Directory -Force | Out-Null
# FModel (GPL-3)
Copy-IfExists (Join-Path $root "LICENSE") (Join-Path $licDst "GPL-3.0-FModel.txt")
Copy-IfExists (Join-Path $root "NOTICE") (Join-Path $licDst "NOTICE-FModel.txt")
# UAssetGUI (MIT)
Copy-IfExists (Join-Path $root "UAssetGUI\LICENSE") (Join-Path $licDst "MIT-UAssetGUI.txt")
Copy-IfExists (Join-Path $root "UAssetGUI\NOTICE.md") (Join-Path $licDst "NOTICE-UAssetGUI.md")
# UAssetAPI (MIT)
Copy-IfExists (Join-Path $root "UAssetAPI\LICENSE") (Join-Path $licDst "MIT-UAssetAPI.txt")
Copy-IfExists (Join-Path $root "UAssetAPI\NOTICE.md") (Join-Path $licDst "NOTICE-UAssetAPI.md")
# CUE4Parse (Apache 2.0)
Copy-IfExists (Join-Path $root "CUE4Parse\LICENSE") (Join-Path $licDst "Apache-2.0-CUE4Parse.txt")
Copy-IfExists (Join-Path $root "CUE4Parse\NOTICE") (Join-Path $licDst "NOTICE-CUE4Parse.txt")
# retoc (MIT)
Copy-IfExists (Join-Path $root "Retoc\LICENSE") (Join-Path $licDst "MIT-retoc.txt")
# -------------------------------------------------------------------------
# Step 5 - Create versioned zip (Release only)
# -------------------------------------------------------------------------
Write-Host ""
if ($Configuration -eq 'Debug') {
Write-Host "Step 5/5 Skipping zip (Debug build)." -ForegroundColor DarkGray
$zipPath = $null
} else {
Write-Host "Step 5/5 Creating versioned zip..." -ForegroundColor Yellow
$zipName = "PakEditor-$Version.zip"
$zipPath = Join-Path $root "publish\$zipName"
if (Test-Path $zipPath) { Remove-Item $zipPath -Force }
Compress-Archive -Path "$out\*" -DestinationPath $zipPath -CompressionLevel Optimal
Write-Host " Zipped -> $zipPath" -ForegroundColor Green
}
# -------------------------------------------------------------------------
# Done
# -------------------------------------------------------------------------
# Check for oo2core — needed by PakEditor.exe for Oodle decompression
$oodle = Join-Path $out "oo2core_9_win64.dll"
if (!(Test-Path $oodle)) {
Write-Host ""
Write-Warning "oo2core_9_win64.dll is missing from the output folder."
Write-Host " Copy it from your Unreal Engine installation or game files:" -ForegroundColor Yellow
Write-Host " e.g. UE_5.x\Engine\Binaries\Win64\oo2core_9_win64.dll" -ForegroundColor Yellow
Write-Host " and place it next to PakEditor.exe before running." -ForegroundColor Yellow
}
Write-Host ""
Write-Host "================================================================" -ForegroundColor Green
Write-Host " Done! Output: $out" -ForegroundColor Green
if ($zipPath) {
Write-Host " Zip: $zipPath" -ForegroundColor Green
}
Write-Host "================================================================" -ForegroundColor Green
Write-Host ""
Write-Host " PakEditor.exe main application"
Write-Host " UAssetGUI\ portable UAssetGUI (v1.0.4+)"
Write-Host " Retoc\ retoc IoStore converter"
Write-Host " README.md user guide"
Write-Host " LICENSE / NOTICE PakEditor (GPL-3)"
Write-Host " licenses\ all third-party license texts"
Write-Host ""
if (!$NoPause) { pause }