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

@ -5,8 +5,7 @@
<SupportedOSPlatformVersion>21</SupportedOSPlatformVersion>
<Nullable>enable</Nullable>
<ApplicationId>com.jordanwages.advanced_calculator</ApplicationId>
<ApplicationVersion>2</ApplicationVersion>
<ApplicationDisplayVersion>1.1</ApplicationDisplayVersion>
<!-- Version info is centralized in src/Directory.Build.props -->
<AndroidPackageFormat>apk</AndroidPackageFormat>
<AndroidEnableProfiledAot>False</AndroidEnableProfiledAot>
</PropertyGroup>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" package="com.jordanwages.advanced_calculator" android:versionCode="2" android:versionName="1.1.0">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" package="com.jordanwages.advanced_calculator">
<uses-permission android:name="android.permission.INTERNET" />
<application android:label="Advanced Calculator" android:icon="@drawable/icon" />
</manifest>

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>