Created
September 15, 2022 15:43
-
-
Save cgytrus/29085a6bf179893666316a36e1c92bf6 to your computer and use it in GitHub Desktop.
BepInEx installer script (BepInEx + ConfigurationManager + HookGenPatcher + LighterPatcher)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add-Type -Assembly System.IO.Compression.FileSystem | |
# Install BepInEx | |
$ArchivePath = "./BepInEx-temp.zip" | |
$LatestRelease = Invoke-RestMethod -Uri https://api.github.com/repos/BepInEx/BepInEx/releases/latest -Method Get | |
foreach($asset in $LatestRelease.assets) { | |
if(!$asset.name.StartsWith("BepInEx_x64_")) { | |
continue | |
} | |
Invoke-WebRequest -uri $asset.browser_download_url -OutFile $ArchivePath | |
Expand-Archive $ArchivePath "." | |
Remove-Item $ArchivePath | |
break | |
} | |
# Install ConfigurationManager | |
$ArchivePath = "./ConfigurationManager-temp.zip" | |
$LatestRelease = Invoke-RestMethod -Uri https://api.github.com/repos/BepInEx/BepInEx.ConfigurationManager/releases/latest -Method Get | |
foreach($asset in $LatestRelease.assets) { | |
if(!$asset.name.StartsWith("BepInEx.ConfigurationManager_")) { | |
continue | |
} | |
Invoke-WebRequest -uri $asset.browser_download_url -OutFile $ArchivePath | |
Expand-Archive $ArchivePath "." | |
Remove-Item $ArchivePath | |
break | |
} | |
New-Item -Path "./BepInEx/" -Name "patchers" -ItemType "directory" | |
# Install HookGenPatcher | |
$DownloadUrl = "https://github.com/harbingerofme/Bepinex.Monomod.HookGenPatcher/releases/latest/download/BepInEx.MonoMod.HookGenPatcher.dll" | |
$DownloadPath = "./BepInEx/patchers/BepInEx.MonoMod.HookGenPatcher.dll" | |
Invoke-WebRequest -uri $DownloadUrl -OutFile $DownloadPath | |
# Install the necessary MonoMod executables (for HookGenPatcher) | |
$ArchivePath = "./MonoMod-temp.zip" | |
# 22.02.10.01 is the latest version HookGenPatcher works with | |
$LatestRelease = Invoke-RestMethod -Uri "https://api.github.com/repos/MonoMod/MonoMod/releases/tags/v22.02.10.01" -Method Get | |
foreach($asset in $LatestRelease.assets) { | |
if(!$asset.name.StartsWith("MonoMod-") -or !$asset.name.EndsWith("-net452.zip")) { | |
continue | |
} | |
Invoke-WebRequest -uri $asset.browser_download_url -OutFile $ArchivePath | |
$zipFile = [IO.Compression.ZipFile]::OpenRead($ArchivePath) | |
foreach($file in $zipFile.Entries | where {$_.Name -eq "MonoMod.exe" -or $_.Name -eq "MonoMod.RuntimeDetour.HookGen.exe"}) { | |
$fileName = $file.Name | |
[System.IO.Compression.ZipFileExtensions]::ExtractToFile($file, "./$fileName", $true) | |
} | |
$zipFile.Dispose() | |
Remove-Item $ArchivePath | |
break | |
} | |
# Install LighterPatcher | |
$DownloadUrl = "https://github.com/harbingerofme/LighterPatcher/releases/latest/download/LighterPatcher.dll" | |
$DownloadPath = "./BepInEx/patchers/LighterPatcher.dll" | |
Invoke-WebRequest -uri $DownloadUrl -OutFile $DownloadPath |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Noice