如何使用PowerShell更新BuildNumber [英] How do I update BuildNumber using PowerShell

查看:91
本文介绍了如何使用PowerShell更新BuildNumber的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为构建步骤,我想从PowerShell脚本更新Build.BuildNumber变量.

I would like to update the Build.BuildNumber variable from a PowerShell script as a build step.

我尝试过:

Write-Host "##vso[task.setvariable variable=BUILD_BUILDNUMBER]1.2.3.4"

Write-Host "##vso[task.setvariable variable=Build.BuildNumber]1.2.3.4"

这没有用.

推荐答案

您需要使用更新内部版本号"功能:

You'd need to use the Update Build Number function:

Write-Host "##vso[build.updatebuildnumber]1.0.0.$($env:Build_BuildId)"

BuildNumber是一种特殊情况.其他变量可以使用您提到的setvariable宏覆盖.

BuildNumber is a special case. Other variables can be overwritten using the setvariable macro you mentioned.

它也会覆盖实际的内部版本号,因此在您声明后,内部版本"概述中的内部版本号"将反映新的版本号.

It will overwrite the actual build number as well so after your statement you Build Number in the Builds overview will reflect the new number.

这里有两项任务可以为您提供帮助.我自己的变量工具箱和变量任务包.使用这些变量,您可以将变量设置为特定值,而当该变量作为输出变量传递时,我自己的任务将自动更正命令以设置内部版本号.该任务包有一个特殊的任务来设置内部版本号.

There are two tasks which may help you out here. My own Variable Toolbox and the Variables Task pack. With those you can set variables to a specific value and while my own task will auto-correct the command to set the buildnumber when that variable is passed as output variable. The Task pack has a special task to set the build number.

这篇关于如何使用PowerShell更新BuildNumber的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆