设置 TFS 构建版本号 PowerShell

Set TFS build version number PowerShell

我知道类似的问题已经存在,但我找不到合适的答案。

我的问题是:是否可以使用 PowerShell 设置新的构建版本号 int TFS?

我想创建内部版本号并通过 PowerShell 进行设置。我想要的就是这样,没有其他解决方案。

谢谢

这个怎么样?

# Change the following to your TFS collection and build URIs...
# These environment variables will exist during TFS builds
[String] $CollectionUrl = "$env:TF_BUILD_COLLECTIONURI"
[String] $BuildUrl = "$env:TF_BUILD_BUILDURI"

# Get the Team Project Collection:
$teamProjectCollection = [Microsoft.TeamFoundation.Client.TfsTeamProjectCollectionFactory]::GetTeamProjectCollection($CollectionUrl)

# Connect to the TFS build service:
$buildServer = $teamProjectCollection.GetService([Microsoft.TeamFoundation.Build.Client.IBuildServer])

# Get the build detail:
$buildDetail = $buildServer.GetBuild($BuildUrl)

# Updating the TFS build number with an example SemVer:
$buildDetail.BuildNumber = "1.2.3-alpha1"

# Make sure to save the changes:
$buildDetail.Save()