From b6483fdbff4494c9906741d52f0d43b7e464b5c9 Mon Sep 17 00:00:00 2001
From: Vorta <179685+Vorta@users.noreply.github.com>
Date: Wed, 11 Nov 2026 19:07:24 +0100
Subject: [PATCH] Handle concurrent bundled WPF cache publication and release
0.12.2
---
CHANGELOG.md | 4 +++
Directory.Build.props | 2 +-
README.md | 2 +-
blender/zstudio_recoil/blender_manifest.toml | 2 +-
docs/agents/releasing.md | 2 +-
src/zStudio.Desktop/MixedModeAssemblies.cs | 33 +++++++++++++++--
src/zStudio.Desktop/packages.lock.json | 4 +--
.../MixedModeCacheTests.cs | 35 +++++++++++++++++++
.../zStudio.Desktop.Tests/packages.lock.json | 10 +++---
tools/zStudio.PreviewCheck/packages.lock.json | 10 +++---
10 files changed, 85 insertions(+), 19 deletions(-)
create mode 100644 tests/zStudio.Desktop.Tests/MixedModeCacheTests.cs
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b3fd36d6..121cb04e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,10 @@
Version numbers follow `MAJOR.MINOR.PATCH`; the 0.x series is under active development. Release tags and downloadable archives use the same version.
+## 0.12.2 — 2026-11-11
+
+- Starting several zStudio instances together no longer fails when WPF libraries are first extracted.
+
## 0.12.1 — 2026-11-11
- MW3 source maps list a mission's valves in the World tree, one per name, each with what it does. A valve's card shows what sets it, its reactions and what waits on it, with links to the vehicles, route nodes and valves involved, and edits its starting value, computed inputs and reactions with pickers; rename, delete and new valves are single undoable changes that keep the files' comments and layout.
diff --git a/Directory.Build.props b/Directory.Build.props
index 556546e6..06783de3 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -18,6 +18,6 @@
Advanced viewer and editor for Zipper Interactive's ZBD files
https://github.com/Vorta/zStudio
git
- 0.12.1
+ 0.12.2
diff --git a/README.md b/README.md
index 7bec9404..e3d08b7b 100644
--- a/README.md
+++ b/README.md
@@ -10,7 +10,7 @@
zStudio is a Windows desktop application. It unpacks RECOIL's retail game files once into an editable source project (the developers' original `data\` and `gamegen\` tree: text resources, glTF models, PNG textures, WAV sounds and build scripts), lets you edit the maps in zStudio or in Blender, and exports new game files from the sources. AI agents can work in the same workspace through local MCP.
-Download **[zStudio v0.12.1](https://github.com/Vorta/zStudio/releases/tag/v0.12.1)** for Windows x64.
+Download **[zStudio v0.12.2](https://github.com/Vorta/zStudio/releases/tag/v0.12.2)** for Windows x64.
zStudio tells you when a newer release is out: **Update available** appears in the status bar; click it for the release page. zStudio asks GitHub's public release API at most once a day and sends nothing but its version; **Help → Check for updates** asks now, and **Help → Check for updates automatically** turns the daily check off. Running zStudio 0.9.6 or older on the same Windows account turns the daily check back on, because older versions drop settings they don't know.
diff --git a/blender/zstudio_recoil/blender_manifest.toml b/blender/zstudio_recoil/blender_manifest.toml
index 7df8eade..f10cc606 100644
--- a/blender/zstudio_recoil/blender_manifest.toml
+++ b/blender/zstudio_recoil/blender_manifest.toml
@@ -1,6 +1,6 @@
schema_version = "1.0.0"
id = "zstudio_recoil"
-version = "0.12.1"
+version = "0.12.2"
name = "zStudio RECOIL"
tagline = "Edit RECOIL glTF models, linked worlds, flags and zones"
maintainer = "Vorta"
diff --git a/docs/agents/releasing.md b/docs/agents/releasing.md
index 719d478e..601b35c8 100644
--- a/docs/agents/releasing.md
+++ b/docs/agents/releasing.md
@@ -29,7 +29,7 @@
- Owner decision (0.9.7): zStudio ships as one self-contained, compressed `zStudio.exe` with only the necessary files beside it. The ZIP root holds exactly `zStudio.exe`, `LICENSE`, `THIRD-PARTY-NOTICES.md` and the Blender extension `zStudio-Blender-extension-.zip` (the extension id inside stays `zstudio_recoil`); README, CHANGELOG, CONTRIBUTING, SECURITY and the user guides are not shipped (**Help** opens the guides online at the installed version's tag). Unsigned.
- `zStudio.exe` is the .NET single-file bundle of `zStudio.Desktop`: `./tools/publish.ps1` publishes it with `-p:StudioPackage=true` (Desktop project: self-contained, single file, native libraries inside, compressed, per-assembly ReadyToRun because the SDK's composite default is larger and starts slower, the single-file analyzer off because its implicit ILLink package breaks locked restores; `Directory.Build.props`: embedded symbols) and renames it from `zStudio.Desktop.exe` (the bundle keeps its assembly name). It deletes the Desktop ReadyToRun intermediates first, so images of an earlier configuration (composite stubs) are never bundled. The icon is the checked-in `src/zStudio.Desktop/Assets/studio.ico` (the owner's artwork).
-- WPF's two mixed-mode (C++/CLI) assemblies of .NET 11, `DirectWriteForwarder.dll` and `System.Printing.dll`, cannot load from a bundle and need `ijwhost.dll` beside them on disk: the package embeds them in `zStudio.Desktop.dll` instead of bundling them (`EmbedMixedModeAssemblies`, `ExcludeMixedModeAssemblies`), and `MixedModeAssemblies` (a module initializer, before WPF's first type) writes them beside the extracted `ijwhost.dll` when WPF first asks and loads them from there; `verify-package.ps1` refuses a bundle that holds them. At run time only six native libraries (WPF's five and the C++/CLI host `ijwhost.dll`) and those two assemblies (about 9 MB together) extract, once per build, to `%TEMP%\.net\zStudio\`; the managed assemblies load from the bundle and `AppContext.BaseDirectory` is the folder of `zStudio.exe`, where the app finds `zStudio-Blender-extension-.zip` (Edit in Blender's install offer, `source_blender_extension`). The installed extension checks its helper by version: `--blender-helper` `info` reports zStudio's version, which must equal the extension's.
+- WPF's two mixed-mode (C++/CLI) assemblies of .NET 11, `DirectWriteForwarder.dll` and `System.Printing.dll`, cannot load from a bundle and need `ijwhost.dll` beside them on disk: the package embeds them in `zStudio.Desktop.dll` instead of bundling them (`EmbedMixedModeAssemblies`, `ExcludeMixedModeAssemblies`), and `MixedModeAssemblies` (a module initializer, before WPF's first type) writes them beside the extracted `ijwhost.dll` when WPF first asks and loads them from there (if another process publishes and loads the same cached assembly first, the writer verifies its complete content before accepting that winner); `verify-package.ps1` refuses a bundle that holds them. At run time only six native libraries (WPF's five and the C++/CLI host `ijwhost.dll`) and those two assemblies (about 9 MB together) extract, once per build, to `%TEMP%\.net\zStudio\`; the managed assemblies load from the bundle and `AppContext.BaseDirectory` is the folder of `zStudio.exe`, where the app finds `zStudio-Blender-extension-.zip` (Edit in Blender's install offer, `source_blender_extension`). The installed extension checks its helper by version: `--blender-helper` `info` reports zStudio's version, which must equal the extension's.
- `THIRD-PARTY-NOTICES.md` holds every licence text (packages with identical texts share one section) and the .NET runtime's licence and notices; a dependency update changes its row and, when its terms change, its section.
- Publishing stages both the package folder and ZIP below `artifacts/` and runs `tools/verify-package.ps1` on that staged pair before replacing `artifacts/zStudio-win-x64/` and `artifacts/zStudio--win-x64.zip`. A rejected package leaves the previous pair intact. Installation keeps backups of both until the new pair is installed; an installation failure restores the previous folder and ZIP, and a failed restoration reports the retained backup paths for recovery. Only a successful installation removes the superseded folder and older ZIPs. A custom `-Output` must also be below `artifacts/`; publication paths must not use directory links. Verification checks: the root inventory; the bundle (a format-6 bundle header, not extract-all, compressed, with `zStudio.Desktop.dll`, its `deps.json` and `runtimeconfig.json` and exactly the five WPF native libraries; no composite ReadyToRun image, symbol files, `.zbd`, `.zrd`, `.bndb`, `.pfx`, `.p12` or `.key`); the notices (every package in the bundled `deps.json` has a row of the same version, every row a shipped package, every row's link a heading of the file); the file and product version of `zStudio.exe`; `LICENSE` and the notices against the checkout; the Blender extension's version and file hashes against its sources; SHA-256 parity of every ZIP entry.
- Manual distribution check: extract into a folder with spaces, start `zStudio.exe` from an unrelated working directory with a dataset path containing spaces and installed-runtime discovery disabled; only the six native libraries and the two mixed-mode assemblies appear under `%TEMP%\.net\zStudio`; the six RT_ICON resources match the six ICO frames.
diff --git a/src/zStudio.Desktop/MixedModeAssemblies.cs b/src/zStudio.Desktop/MixedModeAssemblies.cs
index e20a89fd..a7f2b61b 100644
--- a/src/zStudio.Desktop/MixedModeAssemblies.cs
+++ b/src/zStudio.Desktop/MixedModeAssemblies.cs
@@ -41,10 +41,37 @@ internal static void Install()
/// Writes the assembly unless the folder already holds exactly it (another zStudio of this build may have it loaded).
private static void Write(string path, byte[] bytes)
{
- try { if (File.Exists(path) && File.ReadAllBytes(path).AsSpan().SequenceEqual(bytes)) return; }
- catch (IOException) { }
+ if (Matches(path, bytes)) return;
string temporary = path + "." + Guid.NewGuid().ToString("N") + ".tmp";
- try { File.WriteAllBytes(temporary, bytes); File.Move(temporary, path, overwrite: true); }
+ try { File.WriteAllBytes(temporary, bytes); Publish(temporary, path, bytes); }
finally { try { File.Delete(temporary); } catch (IOException) { } }
}
+
+ // Another process can publish and load this same assembly after our initial check.
+ // Windows then refuses replacement; accept that winner only after verifying its bytes.
+ internal static void Publish(string temporary, string path, byte[] bytes)
+ {
+ try { File.Move(temporary, path, overwrite: true); }
+ catch (IOException) when (Matches(path, bytes)) { }
+ catch (UnauthorizedAccessException) when (Matches(path, bytes)) { }
+ }
+
+ private static bool Matches(string path, byte[] bytes)
+ {
+ try
+ {
+ using FileStream file = new(path, FileMode.Open, FileAccess.Read, FileShare.Read | FileShare.Delete);
+ if (file.Length != bytes.Length) return false;
+ Span chunk = stackalloc byte[4096];
+ for (int offset = 0; offset < bytes.Length; offset += chunk.Length)
+ {
+ int count = Math.Min(chunk.Length, bytes.Length - offset);
+ file.ReadExactly(chunk[..count]);
+ if (!chunk[..count].SequenceEqual(bytes.AsSpan(offset, count))) return false;
+ }
+ return file.ReadByte() == -1;
+ }
+ catch (IOException) { return false; }
+ catch (UnauthorizedAccessException) { return false; }
+ }
}
diff --git a/src/zStudio.Desktop/packages.lock.json b/src/zStudio.Desktop/packages.lock.json
index fa5e1ef2..231b2fc7 100644
--- a/src/zStudio.Desktop/packages.lock.json
+++ b/src/zStudio.Desktop/packages.lock.json
@@ -77,7 +77,7 @@
"type": "Project",
"dependencies": {
"ModelContextProtocol.Core": "[2.4.0, )",
- "zStudio.Application": "[0.12.1, )"
+ "zStudio.Application": "[0.12.2, )"
}
},
"zstudio.rendering": {
@@ -87,7 +87,7 @@
"Vortice.DXGI": "[3.8.3, )",
"Vortice.Direct3D11": "[3.8.3, )",
"Vortice.Direct3D9": "[3.8.3, )",
- "zStudio.Core": "[0.12.1, )"
+ "zStudio.Core": "[0.12.2, )"
}
},
"Clipper2": {
diff --git a/tests/zStudio.Desktop.Tests/MixedModeCacheTests.cs b/tests/zStudio.Desktop.Tests/MixedModeCacheTests.cs
new file mode 100644
index 00000000..32d41951
--- /dev/null
+++ b/tests/zStudio.Desktop.Tests/MixedModeCacheTests.cs
@@ -0,0 +1,35 @@
+using System.IO;
+using Xunit;
+
+namespace zStudio.Desktop.Tests;
+
+public sealed class MixedModeCacheTests
+{
+ [Fact]
+ public void LoadedConcurrentWinnerIsAcceptedOnlyWhenItsBytesMatch()
+ {
+ // A competing cold start can load its published DLL before our writer moves its copy.
+ string root = Path.Combine(Path.GetTempPath(), "zstudio-mixed-cache-" + Guid.NewGuid().ToString("N"));
+ Directory.CreateDirectory(root);
+ try
+ {
+ byte[] expected = [1, 2, 3, 4];
+ string target = Path.Combine(root, "cached.dll"), temporary = Path.Combine(root, "pending.tmp");
+ File.WriteAllBytes(target, expected); File.WriteAllBytes(temporary, expected);
+ using (var loaded = new FileStream(target, FileMode.Open, FileAccess.Read, FileShare.Read))
+ {
+ MixedModeAssemblies.Publish(temporary, target, expected);
+ Assert.Equal(expected, File.ReadAllBytes(target));
+ Assert.True(File.Exists(temporary));
+ }
+ File.WriteAllBytes(target, [9, 8, 7, 6]);
+ using (var loaded = new FileStream(target, FileMode.Open, FileAccess.Read, FileShare.Read))
+ {
+ var error = Record.Exception(() => MixedModeAssemblies.Publish(temporary, target, expected));
+ Assert.True(error is IOException or UnauthorizedAccessException);
+ Assert.Equal(new byte[] { 9, 8, 7, 6 }, File.ReadAllBytes(target));
+ }
+ }
+ finally { Directory.Delete(root, recursive: true); }
+ }
+}
diff --git a/tests/zStudio.Desktop.Tests/packages.lock.json b/tests/zStudio.Desktop.Tests/packages.lock.json
index 037cfb61..583d664d 100644
--- a/tests/zStudio.Desktop.Tests/packages.lock.json
+++ b/tests/zStudio.Desktop.Tests/packages.lock.json
@@ -216,16 +216,16 @@
"CommunityToolkit.Mvvm": "[8.4.2, )",
"NAudio.Core": "[3.3.0, )",
"NAudio.Wasapi": "[3.3.0, )",
- "zStudio.Core": "[0.12.1, )",
- "zStudio.Mcp": "[0.12.1, )",
- "zStudio.Rendering": "[0.12.1, )"
+ "zStudio.Core": "[0.12.2, )",
+ "zStudio.Mcp": "[0.12.2, )",
+ "zStudio.Rendering": "[0.12.2, )"
}
},
"zstudio.mcp": {
"type": "Project",
"dependencies": {
"ModelContextProtocol.Core": "[2.4.0, )",
- "zStudio.Application": "[0.12.1, )"
+ "zStudio.Application": "[0.12.2, )"
}
},
"zstudio.rendering": {
@@ -235,7 +235,7 @@
"Vortice.DXGI": "[3.8.3, )",
"Vortice.Direct3D11": "[3.8.3, )",
"Vortice.Direct3D9": "[3.8.3, )",
- "zStudio.Core": "[0.12.1, )"
+ "zStudio.Core": "[0.12.2, )"
}
},
"Clipper2": {
diff --git a/tools/zStudio.PreviewCheck/packages.lock.json b/tools/zStudio.PreviewCheck/packages.lock.json
index e6635726..23bf23a0 100644
--- a/tools/zStudio.PreviewCheck/packages.lock.json
+++ b/tools/zStudio.PreviewCheck/packages.lock.json
@@ -55,16 +55,16 @@
"CommunityToolkit.Mvvm": "[8.4.2, )",
"NAudio.Core": "[3.3.0, )",
"NAudio.Wasapi": "[3.3.0, )",
- "zStudio.Core": "[0.12.1, )",
- "zStudio.Mcp": "[0.12.1, )",
- "zStudio.Rendering": "[0.12.1, )"
+ "zStudio.Core": "[0.12.2, )",
+ "zStudio.Mcp": "[0.12.2, )",
+ "zStudio.Rendering": "[0.12.2, )"
}
},
"zstudio.mcp": {
"type": "Project",
"dependencies": {
"ModelContextProtocol.Core": "[2.4.0, )",
- "zStudio.Application": "[0.12.1, )"
+ "zStudio.Application": "[0.12.2, )"
}
},
"zstudio.rendering": {
@@ -74,7 +74,7 @@
"Vortice.DXGI": "[3.8.3, )",
"Vortice.Direct3D11": "[3.8.3, )",
"Vortice.Direct3D9": "[3.8.3, )",
- "zStudio.Core": "[0.12.1, )"
+ "zStudio.Core": "[0.12.2, )"
}
},
"Clipper2": {