【问题标题】:Visual Studio Online automatic build version number increment and assembly patchingVisual Studio Online 自动生成版本号增量和程序集修补
【发布时间】:2015-10-21 18:04:46
【问题描述】:

我使用了很长时间的 TeamCity。 AssemblyInfo 修补程序 能够使用 TeamCity 生成和递增的版本号修补所有 assemblyinfo 文件。 Visual Studio Online Build(新的可编写脚本的跨平台版本)是否可以通过某种方式实现?

【问题讨论】:

标签: azure-devops


【解决方案1】:

我创建了一个Bash Script,它会自动替换AssemblyVersion.cs 等文件中的版本号,并且可以在构建步骤中使用,类似于Microsoft 发布的Power Shell Script

#!/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

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

其次,在构建定义的“常规”选项卡中将内部版本号格式设置为 $(BuildDefinitionName)_$(Major).$(Minor).$(Year:yy)$(DayOfYear).$(Rev:rr)

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-09-17
    • 1970-01-01
    • 2011-01-11
    • 2015-06-25
    • 1970-01-01
    • 2012-10-05
    • 2017-07-22
    • 2012-08-31
    相关资源
    最近更新 更多