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)?
            Asked
            
        
        
            Active
            
        
            Viewed 8,204 times
        
    8
            
            
        - 
                    1i just found this. https://msdn.microsoft.com/Library/vs/alm/Build/scripts/index – Mantzas Oct 21 '15 at 19:44
 
1 Answers
8
            
            
        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:

        Ole Albers
        
- 8,715
 - 10
 - 73
 - 166
 
        Alexander Pacha
        
- 9,187
 - 3
 - 68
 - 108
 
