Xamarin.Android android:versionCode android:versionName - From Jenkins Build Server

jonathanpeppers

We have a unique situation where we are deploying a Xamarin.Android app to China to 33 app stores. Hence, our solution has 33 application projects, and we setup Jenkins (running on Windows) to package and sign all our apks (otherwise it would be crazy to make builds).

We also need to modify android:versionCode and android:versionName in the manifest file, by using the ${SVN_REVISION} value from Jenkins. Is there a way to pass these values command line to MSBuild?

Normally we would hand edit this value, but it's not possible because of so many application projects.

Our build parameters right now look like this in Jenkins:

/p:Configuration=Release;AndroidKeyStore=True;AndroidSigningKeyStore=ourkeystore.keystore;AndroidSigningStorePass=ourpassword;AndroidSigningKeyAlias=ouralias;AndroidSigningKeyPass=ourpassword /t:SignAndroidPackage 
jonathanpeppers

Add this to the end of your *.csproj file, before the ending </Project> tag:

  <Target Name="BeforeBuild" Condition=" '$(JENKINS)' == '1' ">
    <XmlPoke XmlInputPath="Properties\AndroidManifest.xml" Namespaces="&lt;Namespace Prefix='android' Uri='http://schemas.android.com/apk/res/android' /&gt;" Query="manifest/@android:versionCode" Value="$(SVN_REVISION)" />
    <XmlPoke XmlInputPath="Properties\AndroidManifest.xml" Namespaces="&lt;Namespace Prefix='android' Uri='http://schemas.android.com/apk/res/android' /&gt;" Query="manifest/@android:versionName" Value="2.0.$(SVN_REVISION)" />
  </Target>

I have Jenkins configured to pass JENKINS=1 and SVN_REVISION. When it goes to build, it modifies AndroidManifest.xml before the build.

I don't know if this will work on xbuild on a Mac or not, depends on if XmlPoke is implemented. I should do a blog post on this.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Maximum Length of Android versionName / versionCode (Manifest)

From Dev

android:versioncode and android:versionname how to make my sdk compatible

From Dev

Cordova Android build versionCode with Gradle

From Dev

Android Get VersionName in Fragment

From Dev

Android Get VersionName in Fragment

From Dev

Get android versionCode in ndk

From Dev

Android versionCode programmatically

From Dev

Use different VersionCode for Debug/Release android gradle build

From Dev

Specify versionCode in android/gradle projects project root build.gradle

From Dev

Build Xamarin Android project error MSB3073 with Jenkins on Mac

From Dev

Xamarin android build failed

From Dev

How to autoincrement versionCode in Android Gradle

From Dev

Android Dev - Android:versioncode won't update

From Dev

Getting versionCode and VersionName from Google Play

From Dev

Android Jenkins ant build fails

From Dev

Android Jenkins build fails with crashlytics

From Dev

Debug keystore for Jenkins and Android build

From Dev

Android Jenkins ant build fails

From Dev

Android-Jenkins: failed to find Build Tools revision 17.0.0 On Jenkins Build Server

From Dev

Xamarin Android Source - Build Error

From Dev

Cannot build xamarin forms android project from commandline using msbuild

From Dev

Any specific rule to assign VersionName in Android?

From Dev

Any specific rule to assign VersionName in Android?

From Dev

What is the right way to define versionName as ext variable in Android build.gradle?

From Dev

Missing Android NDK toolchains directory '\toolchains' when building Xamarin.Android with hosted tfs build server

From Dev

cordova 5.0.0 , android 4.0.2 weird versionCode behavior

From Dev

Find versionnumber and versioncode of apk generated by android studio

From Dev

Override android gradle versionCode form command line

From Dev

Android: versionCode with cordova-plugin-app-version

Related Related

  1. 1

    Maximum Length of Android versionName / versionCode (Manifest)

  2. 2

    android:versioncode and android:versionname how to make my sdk compatible

  3. 3

    Cordova Android build versionCode with Gradle

  4. 4

    Android Get VersionName in Fragment

  5. 5

    Android Get VersionName in Fragment

  6. 6

    Get android versionCode in ndk

  7. 7

    Android versionCode programmatically

  8. 8

    Use different VersionCode for Debug/Release android gradle build

  9. 9

    Specify versionCode in android/gradle projects project root build.gradle

  10. 10

    Build Xamarin Android project error MSB3073 with Jenkins on Mac

  11. 11

    Xamarin android build failed

  12. 12

    How to autoincrement versionCode in Android Gradle

  13. 13

    Android Dev - Android:versioncode won't update

  14. 14

    Getting versionCode and VersionName from Google Play

  15. 15

    Android Jenkins ant build fails

  16. 16

    Android Jenkins build fails with crashlytics

  17. 17

    Debug keystore for Jenkins and Android build

  18. 18

    Android Jenkins ant build fails

  19. 19

    Android-Jenkins: failed to find Build Tools revision 17.0.0 On Jenkins Build Server

  20. 20

    Xamarin Android Source - Build Error

  21. 21

    Cannot build xamarin forms android project from commandline using msbuild

  22. 22

    Any specific rule to assign VersionName in Android?

  23. 23

    Any specific rule to assign VersionName in Android?

  24. 24

    What is the right way to define versionName as ext variable in Android build.gradle?

  25. 25

    Missing Android NDK toolchains directory '\toolchains' when building Xamarin.Android with hosted tfs build server

  26. 26

    cordova 5.0.0 , android 4.0.2 weird versionCode behavior

  27. 27

    Find versionnumber and versioncode of apk generated by android studio

  28. 28

    Override android gradle versionCode form command line

  29. 29

    Android: versionCode with cordova-plugin-app-version

HotTag

Archive