build: centralize app version in Directory.Build.props\n\n- Define AppVersion + PrereleaseLabel as single source of truth\n- Derive Version, AssemblyVersion, FileVersion, InformationalVersion\n- Map Android: ApplicationDisplayVersion (versionName) and ApplicationVersion (versionCode)\n- Remove version fields from Android csproj and manifest

This commit is contained in:
Codex CLI 2025-09-01 03:27:43 -05:00
commit a64cc5a683
3 changed files with 29 additions and 4 deletions

View file

@ -3,4 +3,30 @@
<Nullable>enable</Nullable>
<AvaloniaVersion>11.1.0</AvaloniaVersion>
</PropertyGroup>
<!-- Centralized app versioning for all projects -->
<PropertyGroup Label="Versioning">
<!-- Single source of truth: update these -->
<AppVersion>1.1.0</AppVersion>
<PrereleaseLabel></PrereleaseLabel>
<!-- Derived semantic version pieces -->
<AppVersionMajor>$([System.Text.RegularExpressions.Regex]::Match('$(AppVersion)', '^(\d+)\.(\d+)\.(\d+)').Groups[1].Value)</AppVersionMajor>
<AppVersionMinor>$([System.Text.RegularExpressions.Regex]::Match('$(AppVersion)', '^(\d+)\.(\d+)\.(\d+)').Groups[2].Value)</AppVersionMinor>
<AppVersionPatch>$([System.Text.RegularExpressions.Regex]::Match('$(AppVersion)', '^(\d+)\.(\d+)\.(\d+)').Groups[3].Value)</AppVersionPatch>
<!-- Standard .NET version properties -->
<VersionPrefix>$(AppVersion)</VersionPrefix>
<VersionSuffix Condition=" '$(PrereleaseLabel)' != '' ">$(PrereleaseLabel)</VersionSuffix>
<Version Condition=" '$(PrereleaseLabel)' == '' ">$(VersionPrefix)</Version>
<Version Condition=" '$(PrereleaseLabel)' != '' ">$(VersionPrefix)-$(VersionSuffix)</Version>
<AssemblyVersion>$(AppVersionMajor).$(AppVersionMinor).0.0</AssemblyVersion>
<FileVersion>$(AppVersionMajor).$(AppVersionMinor).$(AppVersionPatch).0</FileVersion>
<InformationalVersion>$(Version)</InformationalVersion>
<!-- Android mapping: versionName + versionCode -->
<ApplicationDisplayVersion>$(Version)</ApplicationDisplayVersion>
<!-- VersionCode = major*10000 + minor*100 + patch (e.g., 1.2.3 -> 10203) -->
<ApplicationVersion>$([MSBuild]::Add($([MSBuild]::Multiply($(AppVersionMajor), 10000)),$([MSBuild]::Add($([MSBuild]::Multiply($(AppVersionMinor), 100)),$(AppVersionPatch)))))</ApplicationVersion>
</PropertyGroup>
</Project>