mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2026-03-26 04:27:28 +08:00
build: auto-sync manifest.json version_number from csproj Version during ZipMod
This commit is contained in:
10
AGENTS.md
10
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.
|
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 `<Version>` 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 `<Version>` during the `ZipMod` target — no manual update of `manifest.json` is needed.
|
||||||
|
|
||||||
|
**Release workflow:**
|
||||||
|
1. Update `<Version>` in the mod's `.csproj` file (e.g., `<Version>1.2.3</Version>`)
|
||||||
|
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
|
## 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.
|
- **Shared library:** `UXAssist` acts as a common library. `CheatEnabler` and `UniverseGenTweaks` reference `UXAssist.csproj` directly to reuse `Common/`, `UI/`, and config panel infrastructure.
|
||||||
|
|||||||
@@ -60,6 +60,10 @@
|
|||||||
<_ZipPath>$(_PackageDir)\$(ProjectName)-$(Version).zip</_ZipPath>
|
<_ZipPath>$(_PackageDir)\$(ProjectName)-$(Version).zip</_ZipPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<!-- Sync manifest.json version_number from .csproj $(Version) before packaging -->
|
||||||
|
<Exec Condition="Exists('$(_PackageDir)\manifest.json')"
|
||||||
|
Command="powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "$f='$(_PackageDir)\manifest.json'; $c=[IO.File]::ReadAllText($f); $c=$c -replace '(\u0022version_number\u0022\s*:\s*\u0022)[^\u0022]*(\u0022)','${1}$(Version)${2}'; [IO.File]::WriteAllText($f,$c,[Text.UTF8Encoding]::new($true))"" />
|
||||||
|
|
||||||
<!-- ── plugins/patchers layout: copy DLL into package/plugins/ first ── -->
|
<!-- ── plugins/patchers layout: copy DLL into package/plugins/ first ── -->
|
||||||
<MakeDir Directories="$(_PackageDir)\plugins"
|
<MakeDir Directories="$(_PackageDir)\plugins"
|
||||||
Condition="'$(PackUsePluginsLayout)' == 'true'" />
|
Condition="'$(PackUsePluginsLayout)' == 'true'" />
|
||||||
|
|||||||
Reference in New Issue
Block a user