?
Thanks Josh for the response.
I ended up using custom Power shell task.
<#
.SYNOPSIS
Script to set assembly version for dot net assmeblies.
.PARAMETERS
.sourceFolder
folder where the source is located.
.newVersion
.assemblyInfoFileNamePattern
name of assembly info file
#>
param(
[string]$sourceFolder,
[string]$newVersion,
[string]$assemblyInfoFileNamePattern
)
if( [string]::IsNullOrEmpty($assemblyInfoFileNamePattern)){
$assemblyInfoFileNamePattern = "*AssemblyInfo*.*"
}
if( [string]::IsNullOrEmpty($newVersion)){
$newVersion = "1.0.0.0"
}
$versionSplit = $newVersion.Split(".")
if($versionSplit.Length -eq 2){
$newVersion = $newVersion + ".*.*"
}
if($versionSplit.Length -eq 3){
$newVersion = $newVersion + ".*"
}
##################################################################################
# Output execution parameters.
"Executing with the following parameters:"
" source Folder: $sourceFolder"
" new Version: $newVersion"
" assembly Info File Name Pattern: $assemblyInfoFileNamePattern"
##################################################################################
$pattern = '[assembly: AssemblyVersion\("(.*)"\)]'
Get-ChildItem -Path $sourceFolder -Filter $assemblyInfoFileNamePattern -Recurse | ForEach{
"found file " + $_.FullName
$fileFound = $_
(Get-Content $fileFound.FullName) | ForEach-Object{
if($_ -match $pattern){
# We have found the matching line
# Edit the version number and put back.
#$fileVersion = [version]$matches[1]
#$targetVersion = "{0}.{1}.{2}.{3}" -f $fileVersion.Major, $fileVersion.Minor, $fileVersion.Build, ($fileVersion.Revision + 1)
'[assembly: AssemblyVersion("{0}")]' -f $newVersion
} else {
# Output line as is
$_
}
} | Set-Content $fileFound.FullName -Force
}