Skip to content

Commit baec6d1

Browse files
committed
Fixed tfs build docs and trim +0 from tfs build number
Fixes #758
1 parent 8207f0d commit baec6d1

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

docs/build-server-support/build-server/tfs-build-vnext.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ See [MSBuild Task](/usage/msbuild-task) for further instructions how to use the
2222
2. For TFS 2015 On-Prem configure Basic Authentication in TFS as shown [here](https://github.com/Microsoft/tfs-cli/blob/master/docs/configureBasicAuth.md).
2323
3. Download the GitVersion TFS build task from the latest release on the [GitVersion releases page](https://github.com/GitTools/GitVersion/releases) and unzip.
2424
4. Run `tfx login` as shown [here](https://github.com/Microsoft/tfs-cli/blob/master/README.md#login).
25-
5. From the directory outside of where you unzipped the task, run `tfx build tasks upload .\GitVersionTfsTask --overwrite` where GitVersionTfsTask is the directory containing the files.
25+
5. From the directory outside of where you unzipped the task, run `tfx build tasks upload --task-path .\GitVersionTfsTask --overwrite` where GitVersionTfsTask is the directory containing the files.
2626
6. It should successfully install.
2727

2828
#### Using the GitVersion custom build step
@@ -35,7 +35,10 @@ The VSO build step can update your build number with GitVersion variables. See b
3535

3636
## Running inside TFS
3737
### Using the GitVersion Variables
38-
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.
38+
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.
39+
40+
To use these variables you can just refer to them using the standard variable syntax. For instance `$(GitVersion_NuGetVersion)` in your nuget pack task to set the version number. Since update 1 there are no known limitations.
41+
3942
See [Variables](/more-info/variables/) for an overview of available variables.
4043

4144

@@ -44,16 +47,12 @@ To use GitVersion's variables in the build name, just add them in the form `$(GI
4447
`/output buildserver` and it will replace those variables with the calculated version.
4548
The TFS GitVersion Build Step (above) handles this too, so if you're already using that, there's nothing extra to configure.
4649

47-
If you currently use `$(rev:.r)` in your build number, that won't work correctly if you
50+
If GitVersion does not find any substitutions it will just default to using `FullSemVer`
51+
52+
**IMPORTANT:** If you currently use `$(rev:.r)` in your build number, that won't work correctly if you
4853
use GitVersion variables as well due to the delayed expansion of the GitVersion vars. Instead,
4954
You might be able to use `$(GitVersion_BuildMetaData)` to achieve a similar result.
5055
See [Variables](/more-info/variables/) for more info on the variables.
5156

52-
5357
#### Known limitations
54-
* 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.
55-
* Due to a known 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.
56-
As a workaround environment variables can be used in custom scripts.
57-
58-
## Create a NuGet package in TFS
59-
If you use a Command Line task to build your NuPkg, use `%GITVERSION_NUGETVERSION%` as the version parameter: `nuget.exe pack path\to\my.nuspec -version %GITVERSION_NUGETVERSION%`
58+
If you are using on premises TFS, make sure you are using at least **TFS 2015 Update 1**, otherwise a few things will not work.

src/GitVersionCore/BuildServers/VsoAgent.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ public override string GenerateSetVersionMessage(VersionVariables variables)
4141
// If no variable substitution has happened, use FullSemVer
4242
if (buildNum == newBuildNum)
4343
{
44-
return string.Format("##vso[build.updatebuildnumber]{0}", variables.FullSemVer);
44+
var buildNumber = variables.FullSemVer.EndsWith("+0") ? variables.FullSemVer.Substring(0, variables.FullSemVer.Length - 2) : variables.FullSemVer;
45+
return string.Format("##vso[build.updatebuildnumber]{0}", buildNumber);
4546
}
4647

4748
return string.Format("##vso[build.updatebuildnumber]{0}", newBuildNum);

0 commit comments

Comments
 (0)