Repository navigation
Expand file tree
/
Copy pathpublish.ps1
More file actions
199 lines (178 loc) · 8.52 KB
/
Copy pathpublish.ps1
File metadata and controls
199 lines (178 loc) · 8.52 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
199
param([string]$Configuration = "Release")
$ErrorActionPreference = "Stop"
$Root = $PSScriptRoot
$DistRoot = Join-Path $Root "dist"
$DistDir = Join-Path $DistRoot "fiveprs"
$CoreZip = Join-Path $DistRoot "fiveprs.zip"
function Info($msg) { Write-Host "[FivePRS] $msg" -ForegroundColor Cyan }
function Ok($msg) { Write-Host "[FivePRS] $msg" -ForegroundColor Green }
function Warn($msg) { Write-Host "[FivePRS] WARNING: $msg" -ForegroundColor Yellow }
# 1. Clean dist
Info "Cleaning previous dist..."
if (Test-Path -LiteralPath $DistRoot) { Remove-Item -LiteralPath $DistRoot -Recurse -Force }
$BinRoot = Join-Path $Root "bin"
if (Test-Path -LiteralPath $BinRoot) { Remove-Item -LiteralPath $BinRoot -Recurse -Force }
$null = New-Item -ItemType Directory -Path "$DistDir\client"
$null = New-Item -ItemType Directory -Path "$DistDir\server"
$null = New-Item -ItemType Directory -Path "$DistDir\plugins"
$null = New-Item -ItemType Directory -Path "$DistDir\callouts"
$null = New-Item -ItemType Directory -Path "$DistDir\apps"
# 2. Build
Info "Building ($Configuration)..."
dotnet build "$Root\FivePRS.sln" -c $Configuration --nologo
if ($LASTEXITCODE -ne 0) { Write-Error "Build failed."; exit 1 }
# 3. Copy fxmanifest, license, readme + config
Copy-Item "$Root\fxmanifest.lua" "$DistDir\fxmanifest.lua"
Copy-Item "$Root\LICENSE" "$DistDir\LICENSE"
Copy-Item "$Root\README.md" "$DistDir\README.md"
Copy-Item "$Root\CHANGELOG.md" "$DistDir\CHANGELOG.md"
Info "Copying config files..."
if (Test-Path "$Root\config") {
Copy-Item -Recurse "$Root\config" "$DistDir\config"
} else {
Warn "config/ folder not found — server will use built-in defaults."
}
Info "Copying NUI files..."
Copy-Item -Recurse "$Root\nui" "$DistDir\nui"
Copy-Item -Recurse "$Root\scripts" "$DistDir\scripts"
# 4-5. Copy the shipped binaries. Only the files listed here are packaged; a new or missing
# file stops the build so every dependency change is a deliberate decision.
$ClientFiles = @(
"FivePRS.Client.net.dll", "FivePRS.Police.net.dll", "FivePRS.Fire.net.dll", "FivePRS.EMS.net.dll",
"FivePRS.Core.dll", "Newtonsoft.Json.dll"
)
$ServerFiles = @(
"FivePRS.Server.net.dll", "FivePRS.Core.dll", "FivePRS.Native.dll", "Newtonsoft.Json.dll",
"Microsoft.Data.Sqlite.dll", "SQLitePCLRaw.batteries_v2.dll", "SQLitePCLRaw.core.dll",
"SQLitePCLRaw.provider.dynamic_cdecl.dll", "SQLitePCLRaw.provider.e_sqlite3.dll",
"System.Buffers.dll", "System.Memory.dll", "System.Numerics.Vectors.dll", "System.Runtime.CompilerServices.Unsafe.dll",
"Windows.dll", "Microsoft.Windows.SDK.NET.dll",
"e_sqlite3.dll", "libe_sqlite3.so"
)
function Copy-Shipped($name, $from, $to, $files) {
Info "Copying $name binaries..."
$built = Get-ChildItem $from -File | Where-Object {
($_.Extension -eq ".dll" -or $_.Extension -eq ".so") -and $_.Name -notlike "CitizenFX.*"
} | ForEach-Object { $_.Name }
$unexpected = $built | Where-Object { $files -notcontains $_ }
$absent = $files | Where-Object { $built -notcontains $_ }
if ($unexpected -or $absent) {
$unexpected | ForEach-Object { Write-Host " NEW (not in the $name list): $_" -ForegroundColor Red }
$absent | ForEach-Object { Write-Host " MISSING from the build: $_" -ForegroundColor Red }
Write-Error "The $name binaries changed. Update the list in publish.ps1 once you've checked the change."
exit 1
}
$files | ForEach-Object { Copy-Item (Join-Path $from $_) -Destination $to }
}
Copy-Shipped "client" "$Root\bin\client" "$DistDir\client" $ClientFiles
Copy-Shipped "server" "$Root\bin\server" "$DistDir\server" $ServerFiles
# 6. Drop READMEs into plugins/, callouts/ and apps/
@(
"FivePRS Plugins Folder",
"========================",
"",
"Drop functionality-extension DLLs here.",
"",
"Examples of what belongs here:",
" - New agency modules (EMS, Fire, etc.)",
" - Custom command packs",
" - HUD / NUI overlay systems",
" - Additional BaseScript modules",
"",
"Building a plugin:",
" - Reference client\FivePRS.Core.dll and client\FivePRS.Client.net.dll",
" - Subclass BaseScript for any systems you need",
" - Build as a net452 Class Library named <Name>.net.dll",
" - Drop the output DLL here and restart fiveprs"
) | Set-Content "$DistDir\plugins\README.txt" -Encoding ASCII
@(
"FivePRS Callouts Folder",
"=========================",
"",
"Drop scenario DLLs here. Each DLL is scanned on startup for",
"[CalloutInfo]-decorated CalloutBase subclasses, which are then",
"registered with the dispatcher automatically.",
"",
"Examples of what belongs here:",
" - Custom police callouts (traffic stop, bank robbery, etc.)",
" - Department-specific scenarios",
"",
"Building a callout pack:",
" - Reference client\FivePRS.Core.dll and client\FivePRS.Client.net.dll",
" - Subclass CalloutBase and annotate with [CalloutInfo(Name, Dept, Weight)]",
" - Build as a net452 Class Library named <Name>.net.dll",
" - Drop the output DLL here and restart fiveprs - no core recompile needed"
) | Set-Content "$DistDir\callouts\README.txt" -Encoding ASCII
@(
"FivePRS Apps Folder",
"=====================",
"",
"Drop terminal app DLLs here. Each TerminalApp subclass becomes an",
"app on the FivePRS terminal home screen.",
"",
"Building an app:",
" - Reference client\FivePRS.Core.dll and client\FivePRS.Client.net.dll",
" - Subclass FivePRS.Client.Terminal.TerminalApp (Id, Label, Icon, Color)",
" - Return an AppScreen from BuildScreen, or set Page to your own HTML",
" page such as apps/myapp/index.html and put the page in apps\myapp\",
" - Build as a net452 Class Library named <Name>.net.dll",
" - Drop the DLL (and its folder) here and restart fiveprs",
"",
"Apps can also come from any resource with exports.fiveprs:registerApp.",
"See the FivePRS README for both."
) | Set-Content "$DistDir\apps\README.txt" -Encoding ASCII
# 7. Verify fxmanifest references (skip comments and wildcard globs)
Info "Verifying manifest references..."
$missing = @()
$activeLines = Get-Content "$DistDir\fxmanifest.lua" | Where-Object { $_ -notmatch "^\s*--" }
$manifestContent = $activeLines -join "`n"
$refs = [regex]::Matches($manifestContent, "(client|server)/[^'*\n]+\.dll") |
ForEach-Object { $_.Value -replace "/", "\" }
foreach ($ref in $refs) {
$full = Join-Path $DistDir $ref
if (-not (Test-Path $full)) { $missing += $ref }
}
if ($missing.Count -gt 0) {
Warn "Files referenced in fxmanifest.lua but missing from dist:"
$missing | ForEach-Object { Write-Host " MISSING: $_" -ForegroundColor Red }
} else {
Ok "All manifest references satisfied."
}
# 8. Zip the resource (the zip contains its top-level folder)
Info "Creating zip archives..."
Add-Type -AssemblyName System.IO.Compression
Add-Type -AssemblyName System.IO.Compression.FileSystem
function New-ResourceZip($sourceDir, $zipPath) {
$source = (Get-Item -LiteralPath $sourceDir).FullName
$prefix = Split-Path $source -Leaf
$zip = [System.IO.Compression.ZipFile]::Open($zipPath, [System.IO.Compression.ZipArchiveMode]::Create)
try {
foreach ($file in Get-ChildItem -LiteralPath $source -Recurse -File) {
$entry = $prefix + "/" + $file.FullName.Substring($source.Length + 1).Replace("\", "/")
$null = [System.IO.Compression.ZipFileExtensions]::CreateEntryFromFile(
$zip, $file.FullName, $entry, [System.IO.Compression.CompressionLevel]::Optimal)
}
} finally {
$zip.Dispose()
}
}
New-ResourceZip $DistDir $CoreZip
# 9. Summary
$fileCount = (Get-ChildItem -LiteralPath $DistDir -Recurse -File).Count
$coreMB = [math]::Round((Get-Item -LiteralPath $CoreZip).Length / 1MB, 2)
Write-Host ""
Ok "Core -> $DistDir ($fileCount files)"
Ok "Zipped -> $CoreZip (~${coreMB} MB)"
Write-Host ""
Write-Host "Next steps:" -ForegroundColor Yellow
Write-Host " 1. Extract fiveprs.zip into your server resources\ directory." -ForegroundColor Yellow
Write-Host " 2. Add to server.cfg:" -ForegroundColor Yellow
Write-Host ' set fiveprs_db_type "sqlite" # or "mysql" (needs oxmysql and mysql_connection_string)' -ForegroundColor Gray
Write-Host ' set fiveprs_restrict_departments "false" # "true" to require ACE per department' -ForegroundColor Gray
Write-Host " ensure fiveprs" -ForegroundColor Gray
Write-Host ""
Write-Host " plugins\ <- drop functionality extensions here" -ForegroundColor Yellow
Write-Host " callouts\ <- drop scenario packs here" -ForegroundColor Yellow
Write-Host " apps\ <- drop terminal apps here" -ForegroundColor Yellow
Write-Host " (restart the resource after adding any DLL - no recompile needed)" -ForegroundColor Yellow
Write-Host ""