Xamarin mobile app version number scheme across 3 platforms

7.7k views Asked by At

There's probably multiple questions here all related. I'm trying to come up with a simple version number update scheme for our 3 mobile apps built from a single xamarin solution.

What I'm looking for is a simple way to keep all these values in sync with one another without having to go around and update them all individually.

  • Windows Phone Version should get set to the AssemblyVersion or FileVersion Automatically
  • IOS Version Number should be set to same. (not sure what the build number should be)
  • Android Version Name should be set to same.
  • Android Version Number should auto increment for each release build.

My current setup requires navigating around to 4 different places to manually sync up the version numbers.

  1. Global Assembly Info

I have a linked file which contains the AssemblyVersion and AssemblyFileVersion that's shared by all PCL and Platform projects in the solution with the following info.

[assembly: AssemblyVersion("2.1.1.*")]
[assembly: AssemblyFileVersion("2.1.1.0")]
  1. Android

Seperately under the android project, I have to manually update the version name and version number (int)

Version Name: 2.1.1
Version Number: 2
  1. IOS

Under the iOS Application tab, I've 2 more fields to fill in.

Version Number: 2.1.1
Build Number: 0 //Not sure if I'm using this field correctly.
  1. Windows Phone

On the "Packaging" tab of the WMAppManifest Property dialog, I have to supply a Version Number as well.

Version Number: 2.1.1.0
2

There are 2 answers

1
Andy Hopper On BEST ANSWER

We've built a tool to synchronize versions between assemblies, Android, and iOS; I've just pushed it to our GitHub repo: https://github.com/soltechinc/soltechxf/. If you clone that repo and build UpdateVersionInfo, it should do what you're looking for.

UpdateVersionInfo.exe:
  -?                          Shows help/usage information.
  -v, --major=VALUE           A numeric major version number greater than zero.
  -m, --minor=VALUE           A numeric minor number greater than zero.
  -b, --build=VALUE           A numeric build number greater than zero.
  -r, --revision=VALUE        A numeric revision number greater than zero.
  -p, --path=VALUE            The path to a C# file to update with version
                              information.
  -a, --androidManifest=VALUE The path to an android manifest file to update
                              with version information.
  -t, --touchPlist=VALUE      The path to an iOS plist file to update with
                              version information.

The default version (i.e., the version you'll get if you supply none of the parameters) is 1.0.0.0.

The tool can use relative or absolute paths to the files, and my recommendation is to follow the approach it already sounds like you're using: have a single version.cs file that you include as a linked file (or in a shared project), and remove any AssemblyInfo attributes that are contained in that Version.cs file.

I should add; the tool currently assumes that you WILL be updating an iOS and an Android project along with the C# code. (I just added a post-it note to myself to make those optional.)

EDIT: Just noticed that past-Andy already noticed that and took care of it (which is a surprise; I usually yell epithets at past-Andy...). If you do not supply a path for the Android manifest or iOS Info.plist, it will skip them.

0
Gabriel Robert On

You could take a look at xavtool.

Typical flow:

$ xavtool current
1.0.1 - androidApp (...\test\AndroidManifest.xml)
1.0.1 - iOSApp (...\test\Info.plist)
1.0.1.0 - uwpApp (...\test\Package.appxmanifest)

$ git flow release start '1.1.0'

$ xavtool i
1.0.1: New version: 1.1.0 (...\test\AndroidManifest.xml)
1.0.1: New version: 1.1.0 (...\test\Info.plist)
1.0.1.0: New version: 1.1.0.0 (...\test\Package.appxmanifest)

$ git commit -am "Version bump to 1.1.0"
$ git flow release finish -p