设置TFS生成版本号PowerShell

设置TFS生成版本号PowerShell,powershell,tfs,Powershell,Tfs,我知道类似的问题已经存在,但我找不到合适的答案 我的问题是:是否可以使用PowerShell设置新的内部版本号int TFS 我想创建生成版本号并通过PowerShell进行设置。我想要的就是这样,没有其他解决方案 谢谢这个怎么样 # Change the following to your TFS collection and build URIs... # These environment variables will exist during TFS builds [String] $C

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

我的问题是:是否可以使用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()

确保首先在工作流中执行此操作,以便生成的名称也匹配。