From b782da4ac54e1072d2857f4a2f77c80c3ef08005 Mon Sep 17 00:00:00 2001 From: mirfalltnixein Date: Fri, 23 Oct 2026 15:04:53 +0200 Subject: [PATCH] Mark run_bepinex.sh as executable in the Linux and macOS zips (#1420) Cake's Zip creates each entry with ZipArchive.CreateEntry and copies the bytes, so file modes on disk are never recorded and every file ends up as 0644. run_bepinex.sh therefore isn't executable after extracting, and users have to chmod +x it before ./run_bepinex.sh %command% works. Set its mode to 0755 after packing. Co-authored-by: mirfalltnixein <22786734+mirfalltnixein@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 --- build/Program.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/build/Program.cs b/build/Program.cs index 1013790..2bdc404 100644 --- a/build/Program.cs +++ b/build/Program.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.IO.Compression; using System.Linq; using System.Text; using Cake.Common; @@ -329,10 +330,18 @@ public sealed class PublishTask : FrostingTask foreach (var dist in ctx.Distributions) { var targetZipName = $"BepInEx-{dist.Target}-{ctx.BuildPackageVersion}.zip"; + var targetZipPath = ctx.DistributionDirectory.CombineWithFilePath(targetZipName); ctx.Log.Information($"Packing {targetZipName}"); - ctx.Zip(ctx.DistributionDirectory.Combine(dist.Target), - ctx.DistributionDirectory - .CombineWithFilePath(targetZipName)); + ctx.Zip(ctx.DistributionDirectory.Combine(dist.Target), targetZipPath); + + // Cake's Zip doesn't keep file modes, so mark the start script as executable by hand + if (dist.Os is "linux" or "macos") + { + using var archive = ZipFile.Open(targetZipPath.FullPath, ZipArchiveMode.Update); + var startScript = archive.GetEntry("run_bepinex.sh"); + if (startScript != null) + startScript.ExternalAttributes = Convert.ToInt32("100755", 8) << 16; + } }