Visual Studio Online自动构建版本号增量和装配修补

问题描述 投票:6回答:1

我正在使用TeamCity很长一段时间。 AssemblyInfo修补程序能够使用由TeamCity生成和增加的版本号修补所有assemblyinfo文件。使用Visual Studio Online Build(新的可编写脚本的,跨平台的)可以实现这种方式吗?

azure-devops
1个回答
6
投票

我已经创建了一个Bash Script,它可以自动替换AssemblyVersion.cs等文件中的版本号,并且可以在构建步骤中使用,类似于Power Shell Script发布的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

首先,为主要版本和次要版本enter image description here创建变量

其次,在构建定义的General选项卡中将build-number格式设置为$(BuildDefinitionName)_$(Major).$(Minor).$(Year:yy)$(DayOfYear).$(Rev:rr)

enter image description here

最后使用上面的脚本创建一个bash-script或Powershell步骤:enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.