Created
October 8, 2019 05:24
-
-
Save Tewr/cb4d4b75f9d0889f70d7519c5f7020dc to your computer and use it in GitHub Desktop.
Azure devops: Put git source version and build date in AssemblyProduct
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# $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