diff --git a/JotunnModStub/RacesOfValheim.csproj b/JotunnModStub/RacesOfValheim.csproj
index 188493c..8553db5 100644
--- a/JotunnModStub/RacesOfValheim.csproj
+++ b/JotunnModStub/RacesOfValheim.csproj
@@ -153,18 +153,10 @@
$(REPO_ROOT)dist\
-
-
- $(IntermediateOutputPath)nexus\
-
-
-
-
-
+
+
diff --git a/scripts/package.ps1 b/scripts/package.ps1
new file mode 100644
index 0000000..9993c0a
--- /dev/null
+++ b/scripts/package.ps1
@@ -0,0 +1,58 @@
+# Builds the Thunderstore and Nexus zips. Called by the PackageThunderstore target in
+# RacesOfValheim.csproj on a Release build.
+#
+# Compress-Archive is not used on purpose: on Windows PowerShell 5.1 it writes entry names with
+# backslashes (Translations\English\items.json). The zip format only allows "/", so extractors
+# on Linux and Steam Deck turned each text file into one flat file with backslashes in its name,
+# Jotunn found no Translations folder, and every text in the mod showed up as [key].
+param(
+ [Parameter(Mandatory)] [string] $Dll,
+ [Parameter(Mandatory)] [string] $Manifest,
+ [Parameter(Mandatory)] [string] $Readme,
+ [Parameter(Mandatory)] [string] $Icon,
+ [Parameter(Mandatory)] [string] $Translations,
+ [Parameter(Mandatory)] [string] $OutDir
+)
+
+$ErrorActionPreference = 'Stop'
+Add-Type -AssemblyName System.IO.Compression
+Add-Type -AssemblyName System.IO.Compression.FileSystem
+
+function New-ModZip([string] $zipPath, [object[]] $entries) {
+ if (Test-Path $zipPath) { Remove-Item $zipPath -Force }
+ $zip = [System.IO.Compression.ZipFile]::Open($zipPath, [System.IO.Compression.ZipArchiveMode]::Create)
+ try {
+ foreach ($e in $entries) {
+ $name = $e.Name.Replace('\', '/')
+ [System.IO.Compression.ZipFileExtensions]::CreateEntryFromFile($zip, $e.Source, $name) | Out-Null
+ }
+ } finally {
+ $zip.Dispose()
+ }
+}
+
+# Every translation file, named by its path under the Translations folder.
+$root = (Resolve-Path $Translations).Path.TrimEnd('\')
+$texts = Get-ChildItem $root -Recurse -File -Filter *.json | ForEach-Object {
+ [pscustomobject]@{ Source = $_.FullName; Rel = $_.FullName.Substring($root.Length + 1) }
+}
+
+# The version is read back out of manifest.json, so manifest.json stays the single place a
+# release is numbered.
+$version = (Get-Content $Manifest -Raw | ConvertFrom-Json).version_number
+
+# Thunderstore gives every package a folder of its own, so the texts sit at the zip root.
+$thunderstore = @(
+ [pscustomobject]@{ Source = $Dll; Name = 'RacesOfValheim.dll' }
+ [pscustomobject]@{ Source = $Manifest; Name = 'manifest.json' }
+ [pscustomobject]@{ Source = $Readme; Name = 'README.md' }
+ [pscustomobject]@{ Source = $Icon; Name = 'icon.png' }
+) + ($texts | ForEach-Object { [pscustomobject]@{ Source = $_.Source; Name = "Translations/$($_.Rel)" } })
+
+# Nexus users unzip straight into plugins, so the texts travel inside a RacesOfValheim folder.
+$nexus = @(
+ [pscustomobject]@{ Source = $Dll; Name = 'RacesOfValheim.dll' }
+) + ($texts | ForEach-Object { [pscustomobject]@{ Source = $_.Source; Name = "RacesOfValheim/Translations/$($_.Rel)" } })
+
+New-ModZip (Join-Path $OutDir "RacesOfValheim_Thunderstore_$version.zip") $thunderstore
+New-ModZip (Join-Path $OutDir "RacesOfValheim_Nexus_$version.zip") $nexus