Skip to content

Instantly share code, notes, and snippets.

@Tewr
Created October 8, 2019 05:24
Show Gist options
  • Save Tewr/cb4d4b75f9d0889f70d7519c5f7020dc to your computer and use it in GitHub Desktop.
Save Tewr/cb4d4b75f9d0889f70d7519c5f7020dc to your computer and use it in GitHub Desktop.
Azure devops: Put git source version and build date in AssemblyProduct
# $Env:SubDirectoryFilter is a custom parameter
$searchPath = "$Env:BUILD_SOURCESDIRECTORY\$Env:SubDirectoryFilter"
$shortCommit = "$Env:BUILD_SOURCEVERSION".Substring(0, 8)
$shortCommit = "@$shortCommit"
$date = [System.DateTime]::Now.ToString("s")
Write-Host "Searching in $searchPath"
Get-ChildItem -Path $searchPath -Recurse -Filter "AssemblyInfo.*" | foreach {
$file = $_.FullName
Write-Host "Extending AssemblyProduct Attribute in $file"
(Get-Content $file -raw) -replace '\[assembly\: AssemblyProduct\(\"([^\"]+)\"\)\]',"[assembly: AssemblyProduct(""`$1 $shortCommit $date"")]" | Set-Content $file
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment