$ver = $env:MY_PACKAGE_VERSION $files = Get-ChildItem -Path "." -Filter AssemblyInfo.cs -Recurse foreach ($file in $files) { $fn = $file.FullName Write-Host "Replacing '$ver' in $fn" $c = Get-Content -Path $fn -Raw $c = $c -replace '(?m)(?<=AssemblyVersion\(").*(?="\))', $ver -replace '(?m)(?<=AssemblyFileVersion\(").*(?="\))', $ver Set-Content -Path $fn -Value $c $c = Get-Content -Path $fn -Raw $n = ([regex]::Matches($c, [Regex]::Escape($ver))).count; Write-Host "Replaced $n times" }
758500cookie-checkReplace version in AssemblyInfo.cs