Repository navigation
Expand file tree
/
Copy pathBuild-Release.ps1
More file actions
61 lines (52 loc) · 2.55 KB
/
Copy pathBuild-Release.ps1
File metadata and controls
61 lines (52 loc) · 2.55 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
param(
[string]$Version = "1.2.2",
[ValidateSet('KK', 'KKS')]
[string]$Game = 'KK',
[string]$GameRoot = ''
)
$ErrorActionPreference = "Stop"
if ([string]::IsNullOrWhiteSpace($GameRoot)) {
# KOIKATU_BUILD_GAME_ROOT is Koikatu-specific by name; KKS keeps its own
# default so a KK env override can never redirect a KKS build.
if ($Game -ne 'KKS') {
$GameRoot = $env:KOIKATU_BUILD_GAME_ROOT
}
}
if ([string]::IsNullOrWhiteSpace($GameRoot)) {
$GameRoot = if ($Game -eq 'KKS') { 'H:\KKS\KKS' } else { 'Z:\Koikatu' }
}
$GameRoot = [IO.Path]::GetFullPath($GameRoot).TrimEnd('\')
$base = Split-Path -Parent $MyInvocation.MyCommand.Path
$project = Join-Path $base "MmdDynamicBoneStabilizer.csproj"
# KKS builds use the dedicated Release-KKS / Debug-KKS configurations, so
# bin and obj stay fully isolated from the KK outputs (see the csproj).
$flavorTag = if ($Game -eq 'KKS') { 'KKS-' } else { '' }
$buildConfig = if ($Game -eq 'KKS') { 'Release-KKS' } else { 'Release' }
$dll = Join-Path $base "bin\$buildConfig\MmdDynamicBoneStabilizer.dll"
$releaseRoot = Join-Path $base "release"
$stage = Join-Path $releaseRoot "MmdDynamicBoneStabilizer-${flavorTag}v$Version"
$pluginDir = Join-Path $stage "BepInEx\plugins\MmdDynamicBoneStabilizer"
$zip = Join-Path $releaseRoot "MmdDynamicBoneStabilizer-${flavorTag}v$Version.zip"
$gameRootProperty = if ($Game -eq 'KKS') { 'KKS_BUILD_GAME_ROOT' } else { 'KOIKATU_BUILD_GAME_ROOT' }
dotnet build $project -c $buildConfig "-p:${gameRootProperty}=$GameRoot"
if ($LASTEXITCODE -ne 0) {
throw "Build failed with exit code $LASTEXITCODE"
}
if (-not (Test-Path -LiteralPath $dll)) {
throw "Build output not found: $dll"
}
if (Test-Path -LiteralPath $stage) {
Remove-Item -LiteralPath $stage -Recurse -Force
}
New-Item -ItemType Directory -Path $pluginDir -Force | Out-Null
Copy-Item -LiteralPath $dll -Destination (Join-Path $pluginDir "MmdDynamicBoneStabilizer.dll") -Force
Copy-Item -LiteralPath (Join-Path $base "README.zh-CN.md") -Destination (Join-Path $stage "README.zh-CN.md") -Force
Copy-Item -LiteralPath (Join-Path $base "CHANGELOG.md") -Destination (Join-Path $stage "CHANGELOG.md") -Force
if (Test-Path -LiteralPath $zip) {
Remove-Item -LiteralPath $zip -Force
}
Compress-Archive -Path (Join-Path $stage "*") -DestinationPath $zip -CompressionLevel Optimal
$hash = (Get-FileHash -LiteralPath $zip -Algorithm SHA256).Hash.ToLowerInvariant()
Set-Content -LiteralPath ($zip + ".sha256") -Value ("$hash " + (Split-Path -Leaf $zip)) -Encoding ascii
Write-Host "Package created: $zip"
Write-Host "SHA256: $hash"