1

For creating my apk and ipa file for my Xamarin.Android and Xamarin.iOS projects with the pipeline I need the version number from the AndroidManifest.xml and Info.plist as a variable for use in my yaml config file. I'm changing the version number before pushing to my build branch.

What ways are there to get the version?

Gabriel Weidmann
  • 756
  • 12
  • 16
  • https://stackoverflow.com/questions/39659273/get-current-apps-build-version-xamarin-android. Pls check this link may help – Ranjit Jun 27 '21 at 15:29
  • 1
    @Ranjit Sorry, but your link has nothing to do with azure devops. I need the version from my app in my build pipeline; I cannot use any android or xamarin code there, just the yaml-config. – Gabriel Weidmann Jun 28 '21 at 06:57
  • Okay, My understanding is wrong about your question. I do not know Kithoras Carzyl. – Ranjit Jun 28 '21 at 08:34

1 Answers1

0

I finally found a way:

The version number is in the AndroidManifest.xml:

<manifest ... android:versionName="1.0.1" ...>

If you got AAPT (Android Asset Packaging Tool, https://androidaapt.com) installed on your device you can use it for retrieving the version like this:

"%ANDROID_HOME%/build-tools/30.0.2/aapt.exe" dump badging "[your-apk-name].apk" | grep "versionName" | sed -e "s/.*versionName='//" -e "s/' .*//"

It will return just the version number:

1.0.1

Just run all of this in a script task in your build pipeline and assign the return value to a local or output variable.

Gabriel Weidmann
  • 756
  • 12
  • 16