i am using for a long time TeamCity. The AssemblyInfo patcher has the ability to patch all assemblyinfo files with a version number that is generated and incremented by TeamCity. Is this somehow possible with Visual Studio Online Build (the new scriptable, cross-platform one)?
I've created a Bash Script which automatically replaces the version number in files such as AssemblyVersion.cs and can be used in a build-step, similar to the Power Shell Script published by Microsoft:
#!/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
First, create variables for Major and Minor version
Second, set the build-number format to $(BuildDefinitionName)_$(Major).$(Minor).$(Year:yy)$(DayOfYear).$(Rev:rr)
in the General tab of your build definition
And finally create a bash-script or a Powershell step with the scripts from above:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With