Skip to content

Instantly share code, notes, and snippets.

@apacha
Last active July 4, 2016 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apacha/ae6cfe11b8ac35d3389085b7e44a3c82 to your computer and use it in GitHub Desktop.
Save apacha/ae6cfe11b8ac35d3389085b7e44a3c82 to your computer and use it in GitHub Desktop.
Replace version-number in Visual Studio Team Service Build
#!/bin/bash
# Sample call: ./ApplyVersionToAssemblies.sh ../Source/ AssemblyInfo.cs XamarinAndroid_1.0.0.1
echo "Script to automatically set the version-number in files (e.g. AssemblyInfo.cs)"
if [ $# -ne 3 ]; then
echo "Usage: $0 path_to_search filename build_number"
exit
fi
# Input is something like XamarinAndroid_1.2.3.4 and we want to extract only the 1.2.3.4
# See http://stackoverflow.com/a/19482947/448357 for more infos
VERSION_NUMBER="${3#*_}"
for file in $(find $1 -name $2); do
echo "Replacing Version string in $file with ${VERSION_NUMBER}"
sed -i '' -e 's/"[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*"/"'${VERSION_NUMBER}'"/' "$file"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment