-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrelease.ps1
57 lines (46 loc) · 1.65 KB
/
release.ps1
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
$array = @("HideAllUI.AISyoujyo", "HideAllUI.HoneySelect2", "HideAllUI.Koikatu", "HideAllUI.PlayHome", "HideAllUI.KoikatsuSunshine")
if ($PSScriptRoot -match '.+?\\bin\\?') {
$dir = $PSScriptRoot + "\"
}
else {
$dir = $PSScriptRoot + "\bin\"
}
$out = $dir + "BepInEx\plugins\"
New-Item -ItemType Directory -Force -Path $out
New-Item -ItemType Directory -Force -Path ($dir + "out\")
# Fix using wrong slashes in zip files
Add-Type -AssemblyName System.Text.Encoding
Add-Type -AssemblyName System.IO.Compression.FileSystem
class FixedEncoder : System.Text.UTF8Encoding {
FixedEncoder() : base($true) { }
[byte[]] GetBytes([string] $s)
{
$s = $s.Replace("\\", "/");
return ([System.Text.UTF8Encoding]$this).GetBytes($s);
}
}
function CreateZip ($element)
{
Remove-Item -Force -Path ($out + "*")
New-Item -ItemType Directory -Force -Path $out
Copy-Item -Path ($dir + $element + ".dll") -Destination $out
Copy-Item -Path ($dir + $element + ".xml") -Destination $out -ErrorAction Ignore
$ver = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($dir + $element + ".dll").FileVersion.ToString()
$zipName = $dir + "out\" + $element + "_" + $ver + ".zip";
Remove-Item -Force -Path $zipName -ErrorAction Ignore
[System.IO.Compression.ZipFile]::CreateFromDirectory($dir + "BepInEx", $zipName, [System.IO.Compression.CompressionLevel]::Optimal, $true, [FixedEncoder]::new())
}
foreach ($element in $array)
{
try
{
CreateZip ($element)
}
catch
{
# retry
CreateZip ($element)
}
}
Remove-Item -Force -Path ($out + "*")
Remove-Item -Force -Path ($dir + "BepInEx") -Recurse