fix: tweak jars use forward-slash entry names; bump pack to 0.9.3

NeoForge's mod scanner rejected brassandsigil_tweaks-1.0.0.jar because
PowerShell 5.1's [ZipFile]::CreateFromDirectory() writes Windows-native
path separators into ZIP entry names on Windows. Entries came out as
"META-INF\neoforge.mods.toml" instead of the spec-required forward-slash
form, so the loader couldn't find the manifest and silently dropped the
jar with "not a valid mod file".

Build-Tweaks.ps1 now opens the archive in 'Create' mode and writes each
file as an explicit ZipArchiveEntry whose name is built from the relative
path with backslashes replaced by forward slashes. Verified the rebuilt
jar lists "META-INF/neoforge.mods.toml" etc.

Pack version 0.9.2 -> 0.9.3 so launchers cached at 0.9.2 see "pack
changed" and re-sync the new tweak jar (their bytes differ; SHA-1 in the
manifest will reflect that).
This commit is contained in:
Matt Sijbers
2026-05-09 22:30:49 +01:00
parent a1331212cb
commit bbba58d1dd
2 changed files with 22 additions and 7 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"$schema": "Brass-and-Sigil pack.lock.json - generated, do not edit by hand unless you know what you are doing", "$schema": "Brass-and-Sigil pack.lock.json - generated, do not edit by hand unless you know what you are doing",
"name": "Brass and Sigil", "name": "Brass and Sigil",
"version": "0.9.2", "version": "0.9.3",
"minecraft": "1.21.1", "minecraft": "1.21.1",
"loader": { "loader": {
"type": "neoforge", "type": "neoforge",
+21 -6
View File
@@ -100,12 +100,27 @@ foreach ($dir in $tweakDirs) {
if (Test-Path $jarPath) { Remove-Item $jarPath -Force } if (Test-Path $jarPath) { Remove-Item $jarPath -Force }
[System.IO.Compression.ZipFile]::CreateFromDirectory( # NB: PowerShell 5.1's [ZipFile]::CreateFromDirectory() writes Windows-
$dir.FullName, # native path separators (\) into ZIP entry names on Windows, producing
$jarPath, # entries like "META-INF\neoforge.mods.toml" instead of the spec-required
[System.IO.Compression.CompressionLevel]::Optimal, # "META-INF/neoforge.mods.toml". NeoForge's mod scanner then can't find
$false # the manifest and silently rejects the jar with "not a valid mod file".
) # We build the archive manually so we control the entry name format.
# 'Create' string maps to ZipArchiveMode.Create -- PowerShell 5.1 doesn't
# auto-load the enum type, so the literal string form is more portable.
$zip = [System.IO.Compression.ZipFile]::Open($jarPath, 'Create')
try {
$sourceLen = $dir.FullName.Length
Get-ChildItem -Path $dir.FullName -Recurse -File | ForEach-Object {
$relPath = $_.FullName.Substring($sourceLen).TrimStart('\','/').Replace('\','/')
$entry = $zip.CreateEntry($relPath, [System.IO.Compression.CompressionLevel]::Optimal)
$entryStream = $entry.Open()
try {
$bytes = [System.IO.File]::ReadAllBytes($_.FullName)
$entryStream.Write($bytes, 0, $bytes.Length)
} finally { $entryStream.Dispose() }
}
} finally { $zip.Dispose() }
$size = (Get-Item $jarPath).Length $size = (Get-Item $jarPath).Length
Write-Host (" built {0,-40} {1,8:N0} bytes" -f $jarName, $size) Write-Host (" built {0,-40} {1,8:N0} bytes" -f $jarName, $size)