Team Foundation Services (TFS) by Microsoft generates its own internal build numbers that are unrelated to the product version you have setup for continuous integration. Fortunately, PowerShell can be used to execute a script on the build agent to retrieve the assembly version and then store the result in a variable that can be used for the rest of the build process.
As a case-example, say that as part of build process, you wanted to create a ZIP archive file that would then be uploaded to a server as part of your build or release cycle and that you would like the generated ZIP archive to contain the standard Microsoft version syntax.
Where the last few steps re:
The PowerShell script step has
Type set to
Inline Script, the
Working folder in
Advanced is set to
\MyProgram\bin is the path on the TFS Agent where the program binaries are generated.
Inline Script is the following:
$AssemblyVersion = (Get-Item .\MyProgram.exe).VersionInfo.FileVersion Write-Host "##vso[task.setvariable variable=AssemblyVersion]$AssemblyVersion"
MyProgram.exeis the name of the executable from which the assembly version should be extracted.
The script sets a VSO variable named "AssemblyVersion" that can then be referenced in ulterior steps. For instance, the
Archive files build step in this example, will create a ZIP archive with
Archive file to create set to
This will generate a file such as
MyProgram-10.23.8754.3424.zip that can then be further published via your setup distribution services.