release.ps1: build the multipart upload by hand

Windows PowerShell (.NET Framework) writes form-data names without quotes and a quoted
boundary, which the keymaster's parser rejected ("Send multipart/form-data"). Saved with
BOM so PowerShell 5.1 reads the umlauts correctly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-02 23:51:08 +02:00
co-authored by Claude Opus 5.5
parent 461d94c5fc
commit 166f873669
+15 -6
View File
@@ -1,4 +1,4 @@
# Neue Version automatisch auf den Keymaster hochladen (msco.mbm.wtf -> /download, Launcher-Updates). # Neue Version automatisch auf den Keymaster hochladen (msco.mbm.wtf -> /download, Launcher-Updates).
# Läuft nach dem Release-Build von selbst (MSCO.csproj bzw. MSCO.Launcher.csproj) - oder von Hand: # Läuft nach dem Release-Build von selbst (MSCO.csproj bzw. MSCO.Launcher.csproj) - oder von Hand:
# powershell -ExecutionPolicy Bypass -File release.ps1 -Product mod -File bin\Release\MSCO.dll # powershell -ExecutionPolicy Bypass -File release.ps1 -Product mod -File bin\Release\MSCO.dll
# #
@@ -57,12 +57,21 @@ Add-Type -AssemblyName System.Net.Http
$client = New-Object System.Net.Http.HttpClient $client = New-Object System.Net.Http.HttpClient
$client.Timeout = [TimeSpan]::FromMinutes(10) $client.Timeout = [TimeSpan]::FromMinutes(10)
$client.DefaultRequestHeaders.Authorization = New-Object System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", $token) $client.DefaultRequestHeaders.Authorization = New-Object System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", $token)
$form = New-Object System.Net.Http.MultipartFormDataContent # Multipart von Hand: Windows PowerShell (.NET Framework) schreibt name=... ohne Anführungszeichen und die Boundary in
$form.Add((New-Object System.Net.Http.StringContent($Product)), "product") # Anführungszeichen - das lehnt der Parser des Keymasters (Node/undici) ab.
$form.Add((New-Object System.Net.Http.StringContent($Version)), "version") $boundary = "----MSCO" + [Guid]::NewGuid().ToString("N")
$form.Add((New-Object System.Net.Http.StringContent($Changelog)), "changelog") $utf8 = New-Object System.Text.UTF8Encoding($false)
$body = New-Object System.IO.MemoryStream
function Write-Text([string]$text) { $b = $utf8.GetBytes($text); $body.Write($b, 0, $b.Length) }
foreach ($field in @(@("product", $Product), @("version", $Version), @("changelog", $Changelog))) {
Write-Text "--$boundary`r`nContent-Disposition: form-data; name=`"$($field[0])`"`r`nContent-Type: text/plain; charset=utf-8`r`n`r`n$($field[1])`r`n"
}
$bytes = [System.IO.File]::ReadAllBytes((Resolve-Path $File)) $bytes = [System.IO.File]::ReadAllBytes((Resolve-Path $File))
$form.Add((New-Object System.Net.Http.ByteArrayContent(,$bytes)), "file", [System.IO.Path]::GetFileName($File)) Write-Text "--$boundary`r`nContent-Disposition: form-data; name=`"file`"; filename=`"$([System.IO.Path]::GetFileName($File))`"`r`nContent-Type: application/octet-stream`r`n`r`n"
$body.Write($bytes, 0, $bytes.Length)
Write-Text "`r`n--$boundary--`r`n"
$form = New-Object System.Net.Http.ByteArrayContent(,$body.ToArray())
$form.Headers.TryAddWithoutValidation("Content-Type", "multipart/form-data; boundary=$boundary") | Out-Null
try { try {
$res = $client.PostAsync("$keymaster/api/releases/upload", $form).GetAwaiter().GetResult() $res = $client.PostAsync("$keymaster/api/releases/upload", $form).GetAwaiter().GetResult()