Skip to content

Commit 5d8d989

Browse files
committed
Merge pull request #665 from pascalberger/VSOBuildNo
Update build version from VSO Agent task.
2 parents c05f4f4 + 0ce9ad0 commit 5d8d989

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

docs/more-info/build-server-setup/tfs-build-vnext.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ See [MSBuild Task](/usage/#msbuild-task) for further instructions how to use the
1414
3. Set the Tool parameter to `<pathToGitVersion>\GitVersion.exe`.
1515
4. Set the Arguments parameter to `/output buildserver /nofetch`.
1616
5. If you want the GitVersionTask to update AssemblyInfo files add `updateAssemblyInfo true` to the Arguments parameter.
17+
6. If you want to update the build number you need to send a [logging command](https://github.com/Microsoft/vso-agent-tasks/blob/master/docs/authoring/commands.md) to TFS.
1718

1819
### Using the custom GitVersion build step
1920
#### Installing/updating the custom build step
@@ -29,13 +30,15 @@ From a TFS build definition, select "Add a Step" and then in the Build category,
2930

3031
If you want the GitVersionTask to update AssemblyInfo files, check the box in the task configuration. For advanced usage, you can pass additional options to the GitVersion exe in the Additional arguments section.
3132

33+
The VSO build step updates the build number automatically to the GitVersion number.
34+
3235
## Running inside TFS
3336
### Using the GitVersion Variables
3437
GitVersion passes variables in the form of `GitVersion.*` (Eg: `GitVersion.Major`) to TFS Build and also writes `GITVERSION_*` (Eg: `GITVERSION_MAJOR`) environment variables that are available for any subsequent build step.
3538
See [Variables](/more-info/variables/) for an overview of available variables.
3639

3740
#### Known limitations
38-
* Due to [current limitations in TFS](https://github.com/Microsoft/vso-agent-tasks/issues/380) it's currently not possible to automatically set the TFS build name to the version detected by GitVersion.
41+
* Due to [current limitations in TFS2015 On-Prem](https://github.com/Microsoft/vso-agent-tasks/issues/380) it's currently not possible to automatically set the build version in TFS2015 On-Prem. Instead a warning similar to `##[warning]Unable to process logging event:##vso[build.updatebuildnumber 1.0.0-unstable.1` is logged.
3942
* Due to a know limitation in TFS 2015 On-Prem it's currently not possible to use variables added during build in inputs of subsequent build tasks, since the variables are processed at the beginning of the build.
4043
As a workaround environment variables can be used in custom scripts.
4144

src/GitVersionCore.Tests/BuildServers/VsoAgentTests.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ public void Develop_branch()
1010
{
1111
var versionBuilder = new VsoAgent();
1212
var vsVersion = versionBuilder.GenerateSetVersionMessage("0.0.0-Unstable4");
13-
// Assert.AreEqual("##vso[task.setvariable variable=GitBuildNumber;]0.0.0-Unstable4", vsVersion);
14-
15-
vsVersion.ShouldBe(null);
13+
vsVersion.ShouldBe("##vso[build.updatebuildnumber]0.0.0-Unstable4");
1614
}
1715

1816
[Test]

src/GitVersionCore/BuildServers/VsoAgent.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ public override string GetCurrentBranch()
2424

2525
public override string GenerateSetVersionMessage(string versionToUseForBuildNumber)
2626
{
27-
// Note: the VSO agent does not yet support updating the build display number from a variable
28-
return null;
27+
return string.Format("##vso[build.updatebuildnumber]{0}", ServiceMessageEscapeHelper.EscapeValue(versionToUseForBuildNumber));
2928
}
3029
}
3130
}

0 commit comments

Comments
 (0)