Do you know how inject commit id into file version, so every assembly would heve version like 2.0.6565.0
where 6565 is related to C6565
commit ID in TFS ?
It looks some power shell script is needed.
Do you know how inject commit id into file version, so every assembly would heve version like 2.0.6565.0
where 6565 is related to C6565
commit ID in TFS ?
It looks some power shell script is needed.
If your question is similar to your another post TFS 2015. the $(var.SourceLocation) variable is not available at gated-check in, that want to get the changeset id that hasn't checked in during gated check-in, then it's impossible in a single build.
If you don't use gated check in, then you can use $Env:BUILD_SOURCEVERSION
in a powershell script to set the AssemblyVersion. Here is already a script at the website below, you can refer to it:
Finally I created my own PS script based on this post. The idea update version in all files with assembly info
$CommitId = ([string]$env:BUILD_SOURCEVERSION) -replace "[^0-9]+", ""
$AllVersionFiles = Get-ChildItem $SourceDir AssemblyInfo.cs -recurse
$regexToFindVersion = "Version\(""([0-9]+)\.([0-9]+).+"""
foreach ($file in $AllVersionFiles)
{
Write-Host "Processing " $file.FullName
(Get-Content $file.FullName) |
%{$_ -replace $regexToFindVersion, ('Version("$1.$2.0.' + $CommitId + '"') } |
Set-Content $file.FullName -Force
}
Full script can be found here.