Skip to content
Codeblack edited this page May 25, 2017 · 21 revisions

TFSBuildScripts

This project provides a PowerShell script that can be used for versioning as part of a TFS Build.

The project started with multiple scripts for extending the TFS XAML Builds, including triggering a Sonar-analysis, packaging & publishing NuGet packages and triggering a release. With the introduction of task-based builds in TFS 2015 these tasks are provided by TFS. To learn more about the old version of this project, go to the XAML-Home page.

Status

This project now only includes the Update-Version script. You can add it to your solution by adding the Update-Version.ps1 script manually.

The NuGet package is still available. Version 2.0.0 and upwards only contains the Update-Version script. The latest version for XAML Builds is 1.5.0.

Usage

The Update-Version script takes a version and applies it to version-attributes in C#, VB.NET, F# and C++. By default, the version is taken from the end of the build-number, but it can also be provided explicitly; in both cases TFS build-variables can be used.

I like to use SemVer, even though not all version-attributes support it. Here is how I usually do versioning in builds:

  • Add a Version variable to the build-definition and provide a value based on SemVer; don't forget to update this value depending on the types of changes you're applying to your code
  • Set the Build Number Format of the build-definition to '$(BuildDefinitionName)_$(Version)-ci+$(Rev:rrrr)'; each time the Version variable is changed, the revision number will restart at 1
  • Add the Update-Version.ps1 script to the solution
  • Add a PowerShell Script task to the start of the build-definition and set it to run the Update-Version.ps1 script, that was just added to the solution, with no arguments; the default formatting will use the SemVer-formatted version where possible, and the #.#.#.B (Version with revision) for .NET versions.

For more information about the script-arguments and the formatting, see the Update-Version page.