2

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

1 Answer 1

3

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()
Sign up to request clarification or add additional context in comments.

1 Comment

Make sure that you do this first in the workflow so that the name of the build also matches.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.