Differences

This shows you the differences between two versions of the page.

Link to this comparison view

fuss:team_foundation_services [2018/04/21 09:08] (current)
office created
Line 1: Line 1:
 +====== Get Assembly Version using PowerShell in Build Process ======
 +
 +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.
 +
 +A build process would look like the following:
 +{{fuss:​fuss_team_foundation_services_assembly_version.png?​512}}
 +
 +Where the last few steps re:
 +  - PowerShell script,
 +  - Archive files,
 +  - Upload.
 +
 +The PowerShell script step has ''​Type''​ set to ''​Inline Script'',​ the ''​Working folder''​ in ''​Advanced''​ is set to ''​$(Build.Repository.LocalPath)\MyProgram\bin''​ where ''​\MyProgram\bin''​ is the path on the TFS Agent where the program binaries are generated.
 +
 +
 +Finally, the ''​Inline Script''​ is the following:
 +<code powershell>​
 +$AssemblyVersion = (Get-Item .\MyProgram.exe).VersionInfo.FileVersion
 +Write-Host "##​vso[task.setvariable variable=AssemblyVersion]$AssemblyVersion"​
 +</​code>​
 +where:
 +  * ''​MyProgram.exe''​ is 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 ''​$(Build.ArtifactStagingDirectory)\MyProgram-$(AssemblyVersion).zip''​.
 +
 +This will generate a file such as ''​MyProgram-10.23.8754.3424.zip''​ that can then be further published via your setup distribution services.
  

fuss/team_foundation_services.txt ยท Last modified: 2018/04/21 09:08 by office

Access website using Tor Access website using i2p


For the copyright, license, warranty and privacy terms for the usage of this website please see the license, privacy and plagiarism pages.