Skip to content

Instantly share code, notes, and snippets.

@cgytrus
Created September 15, 2022 15:43
Show Gist options
  • Save cgytrus/29085a6bf179893666316a36e1c92bf6 to your computer and use it in GitHub Desktop.
Save cgytrus/29085a6bf179893666316a36e1c92bf6 to your computer and use it in GitHub Desktop.
BepInEx installer script (BepInEx + ConfigurationManager + HookGenPatcher + LighterPatcher)
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
@Hassunaama
Copy link

Noice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment