From d7f8dc55d4e953663af613059d7c995f1caf1b49 Mon Sep 17 00:00:00 2001 From: Soar Qin Date: Sun, 22 Mar 2026 14:59:28 +0800 Subject: [PATCH] build: auto-sync manifest.json version_number from csproj Version during ZipMod --- AGENTS.md | 10 ++++++++++ Directory.Build.targets | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/AGENTS.md b/AGENTS.md index 7646c9f..7a10c07 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -127,6 +127,16 @@ dotnet build -t:CopyToParentPackage -c Release ``` This copies the preloader DLL into the sibling main mod's `package/patchers/` directory, ready to be zipped by the main mod's `ZipMod` target. +### Version Management + +Each mod's `` property in its `.csproj` file is the **single source of truth** for the version number. The `version_number` field in `package/manifest.json` is automatically synchronized from `` during the `ZipMod` target — no manual update of `manifest.json` is needed. + +**Release workflow:** +1. Update `` in the mod's `.csproj` file (e.g., `1.2.3`) +2. Run `dotnet build -t:ZipMod -c Release` — `manifest.json` is updated automatically before packaging + +The sync is implemented as an inline PowerShell `Exec` step inside the `ZipMod` target in `Directory.Build.targets`. It uses a regex replace that preserves the original UTF-8 BOM encoding and CRLF line endings of `manifest.json`. Preloader projects (which have no `manifest.json`) are safely skipped via a `Condition="Exists(...)"` guard. + ## Key Architectural Patterns - **Shared library:** `UXAssist` acts as a common library. `CheatEnabler` and `UniverseGenTweaks` reference `UXAssist.csproj` directly to reuse `Common/`, `UI/`, and config panel infrastructure. diff --git a/Directory.Build.targets b/Directory.Build.targets index 6ee9f69..74c5463 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -60,6 +60,10 @@ <_ZipPath>$(_PackageDir)\$(ProjectName)-$(Version).zip + + +