-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPackage.ps1
More file actions
72 lines (58 loc) · 2.57 KB
/
Package.ps1
File metadata and controls
72 lines (58 loc) · 2.57 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
# Package.ps1 - builds ModSync and creates a Thunderstore-ready zip
# Usage: .\Package.ps1
# .\Package.ps1 -SkipBuild (skip dotnet build, re-package last build)
param(
[switch]$SkipBuild
)
$ErrorActionPreference = "Stop"
$ProjectRoot = $PSScriptRoot
$AssemblyName = "ModSync"
$BuildOutput = Join-Path $ProjectRoot "bin\Release\$AssemblyName.dll"
$TSAssets = Join-Path $ProjectRoot "Thunderstore"
$StagingDir = Join-Path $ProjectRoot "bin\Package"
$OutDir = Join-Path $ProjectRoot "bin\Release"
# --- 1. Read version from manifest.json ---
$Manifest = Get-Content (Join-Path $TSAssets "manifest.json") | ConvertFrom-Json
$Version = $Manifest.version_number
$ZipName = "$AssemblyName-$Version.zip"
$ZipPath = Join-Path $OutDir $ZipName
# --- 2. Build ---
if (-not $SkipBuild) {
Write-Host "Building $AssemblyName v$Version (Release)..." -ForegroundColor Cyan
dotnet build "$ProjectRoot\$AssemblyName.csproj" -c Release
if ($LASTEXITCODE -ne 0) { throw "Build failed." }
}
if (-not (Test-Path $BuildOutput)) {
throw "DLL not found at: $BuildOutput -- Run without -SkipBuild first."
}
# --- 3. Check for icon.png ---
$IconPath = Join-Path $TSAssets "icon.png"
if (-not (Test-Path $IconPath)) {
Write-Warning "icon.png not found in Thunderstore/. Thunderstore requires a 256x256 PNG icon."
Write-Warning "Add one at: $IconPath"
Write-Warning "Continuing without icon -- the package will be rejected by Thunderstore until one is added."
}
# --- 4. Stage package contents ---
Write-Host "Staging package..." -ForegroundColor Cyan
if (Test-Path $StagingDir) { Remove-Item $StagingDir -Recurse -Force }
New-Item -ItemType Directory -Path "$StagingDir\BepInEx\plugins\$AssemblyName" -Force | Out-Null
# Thunderstore root files
Copy-Item (Join-Path $TSAssets "manifest.json") $StagingDir
Copy-Item (Join-Path $TSAssets "README.md") $StagingDir
Copy-Item (Join-Path $TSAssets "CHANGELOG.md") $StagingDir
if (Test-Path $IconPath) {
Copy-Item $IconPath $StagingDir
}
# Plugin DLL
Copy-Item $BuildOutput "$StagingDir\BepInEx\plugins\$AssemblyName\$AssemblyName.dll"
# --- 5. Zip ---
Write-Host "Creating $ZipName..." -ForegroundColor Cyan
if (Test-Path $ZipPath) { Remove-Item $ZipPath -Force }
Compress-Archive -Path "$StagingDir\*" -DestinationPath $ZipPath
# --- 6. Done ---
$Size = [math]::Round((Get-Item $ZipPath).Length / 1KB, 1)
Write-Host ""
Write-Host "Done! Package ready:" -ForegroundColor Green
Write-Host " $ZipPath ($Size KB)" -ForegroundColor Green
Write-Host ""
Write-Host "Upload at: https://thunderstore.io/c/peak/create/" -ForegroundColor DarkCyan