Azure devops Visual Studio Online自动生成版本号增量和程序集修补

Azure devops Visual Studio Online自动生成版本号增量和程序集修补,azure-devops,Azure Devops,我使用TeamCity很长时间了。 AssemblyInfo修补程序能够使用TeamCity生成并递增的版本号修补所有AssemblyInfo文件。 Visual Studio Online Build(新的可编写脚本的跨平台版本)是否有可能实现这一点?我创建了一个自动替换AssemblyVersion.cs等文件中的版本号并可在生成步骤中使用,类似于发布者: 首先,为主要版本和次要版本创建变量 其次,在生成定义的常规选项卡中将生成编号格式设置为$(BuildDefinitionName)$(

我使用TeamCity很长时间了。 AssemblyInfo修补程序能够使用TeamCity生成并递增的版本号修补所有AssemblyInfo文件。 Visual Studio Online Build(新的可编写脚本的跨平台版本)是否有可能实现这一点?

我创建了一个自动替换AssemblyVersion.cs等文件中的版本号并可在生成步骤中使用,类似于发布者:

首先,为主要版本和次要版本创建变量

其次,在生成定义的常规选项卡中将生成编号格式设置为
$(BuildDefinitionName)$(Major)。$(Minor)。$(Year:yy)$(DayOfYear)。$(Rev:rr)

最后使用上面的脚本创建bash脚本或Powershell步骤:

我刚找到这个。
#!/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