kat1330
kat1330

Reputation: 5332

Set TFS build version number PowerShell

I know that similar question already exist, but I cannot find appropriate answer.

My question is: Is it possible to set new build version number int TFS with PowerShell?

I want to create build version number and set through PowerShell. I want exactly like that, no other solutions.

Thanks

Upvotes: 2

Views: 719

Answers (1)

Johnny 5
Johnny 5

Reputation: 507

How about this?

# 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()

Upvotes: 3

Related Questions