title: AppCenter bash script to change the Version Name in Android Manifest file
body: <p>I created a CI CD in AppCenter for my Android app made with Xamarin Forms and I'm trying to change the Version Name in the Manifest file with a custom script.
  I tried some approaches, mainly from <a href="https://montemagno.com/vs-app-center-custom-build-scripts-for-production-apps/" rel="nofollow noreferrer">this post from Montemagno</a> but with no success.</p>
  <p>I have seen the use of this <code>BUILD_REPOSITORY_LOCALPATH</code> and <code>APPCENTER_SOURCE_DIRECTORY</code> variables in the script, tried both and didn't work.</p>
  <p>My manifest file is located in this path: <code>src/Dashview.Mobile/Dashview.Mobile.Android/Properties/AndroidManifest.xml</code></p>
  <p>and my script is like:</p>
  <pre><code>#!/usr/bin/env bash
  
  # Updating Manifest
  
  MANIFEST=&quot;$APPCENTER_SOURCE_DIRECTORY/src/Dashview.Mobile/Dashview.Mobile.Android/Properties/AndroidManifest.xml&quot;
  
  VERSIONNAME=`grep versionName ${MANIFEST} | sed 's/.*versionName\s*=\s*\&quot;\([^\&quot;]*\)\&quot;.*/\1/g'`
  
  sed -i.bak &quot;s/android:versionName=&quot;\&quot;${VERSIONNAME}\&quot;&quot;/android:versionName=&quot;\&quot;1.0.${APPCENTER_BUILD_ID}\&quot;&quot;/&quot; ${MANIFEST}
  
  rm -f ${MANIFEST}.bak
  
  # Print out file for reference
  cat $MANIFEST
  
  echo 
  </code></pre>
  <p>The script is located in the root of the Xamarin.Android project and is a pre-build with a name appcenter-pre-build.sh</p>
  <p>In the generated log, I can't see that the manifest was changed with the cat command, it gets recognized by AppCenter because I can see the Pre-build badge but it's like not being executed because my App is always in the 1.0.0 version.</p>
  <p>If anybody has done something like this, I'll appreciate the help!</p>