In a XAML build definition, there was a parameter "Get Version". (Example)
I couldn't find the same functionality in the new TFS 2015 build system, nor on Visual Studio Online / Visual Studio Team Services.
As an alternative, I could make a branch from a specific version and build that, but this seems like a dirty solution.