# Versioning Utilities for .NET (MAUI)
A set of tools designed to help manage version numbers in build pipelines, specifically tailored for .NET MAUI applications. This extension helps ensure your apps comply with Google Play Console and Apple App Store version requirements.
Tasks included
Prepare Version with Build ID
This task processes a MAUI project file to extract the current version and replace the last segment with the build ID. It also generates a unique build number that follows store requirements for version incrementation.
Parameters
- Project File Name: The name of the project file (e.g., MyApp.csproj)
Output Variables
The task sets two output variables:
- vtBuildNumber: A unique build number in
yyyyMMdd$(Rev:rr)
format (e.g., 20240715-01
)
- vtVersionName: The semantic version extracted from the project with the last segment replaced by the Build.BuildId (e.g.,
1.2.145
)
Store Versioning Requirements
This task helps you comply with the unique versioning requirements of mobile app stores:
- Google Play Console: Requires each app update to have a higher
versionCode
(our vtBuildNumber
) than the previous version
- Apple App Store: Requires each release to have a unique build number and a version string that follows semantic versioning
Example Usage
Example Values
If your MAUI project has an ApplicationDisplayVersion
of 1.2.3
and you're running build #145 on July 15, 2024, after running the task:
vtBuildNumber
will be set to: 20240715-01
(increments to 20240715-02
, 20240715-03
, etc. on subsequent builds)
vtVersionName
will be set to: 1.2.145
Pipeline Example
Here's how to use the task in your YAML pipeline:
steps:
- task: PrepareVersion@1
inputs:
projectFileName: 'PlayerApp.csproj'
displayName: 'Prepare Version Numbers'
# Using the variables to publish an Android app
- task: DotNetCoreCLI@2
inputs:
command: 'publish'
publishWebProjects: false
zipAfterPublish: false
projects: '**/PlayerApp.csproj'
arguments: '-c Release -f net9.0-android -o "$(Build.ArtifactStagingDirectory)/$(BuildConfiguration)/"
/p:AndroidPackageFormat=aab
/t:SignAndroidPackage
/p:ApplicationDisplayVersion="$(vtVersionName)"
/p:ApplicationVersion="$(vtBuildNumber)"
/p:AndroidKeyStore="True"
For iOS
- task: DotNetCoreCLI@2
inputs:
command: 'publish'
publishWebProjects: false
projects: '**/PlayerApp.csproj'
arguments: '-c Release -f net9.0-ios -o "$(Build.ArtifactStagingDirectory)/$(BuildConfiguration)/"
/p:ApplicationDisplayVersion="$(vtVersionName)"
/p:ApplicationVersion="$(vtBuildNumber)"
/p:ArchiveOnBuild=true
/p:MtouchLink=SdkOnly'
- task: DotNetCoreCLI@2
inputs:
command: 'publish'
publishWebProjects: false
projects: '**/PlayerApp.csproj'
arguments: '-c Release -f net9.0-android;net9.0-ios -o "$(Build.ArtifactStagingDirectory)/$(BuildConfiguration)/"
/p:ApplicationDisplayVersion="$(vtVersionName)"
/p:ApplicationVersion="$(vtBuildNumber)"'
Benefits
- Consistent Versioning: Ensures consistent version numbers across all build artifacts
- Compliance: Automatically meets Google Play and Apple App Store versioning requirements
- Traceability: Build numbers directly connect to specific source commits
- Automation: No need for manual version bumping before each release
Notes
- The task automatically detects version information in your MAUI project files
- Build numbers will reset each day, which helps keep version numbers clean and manageable
- For Android,
ApplicationVersion
is mapped to versionCode
- For iOS,
ApplicationVersion
is mapped to CFBundleVersion