Created
January 6, 2016 23:04
-
-
Save FeodorFitsner/82dad08650d72268e48d to your computer and use it in GitHub Desktop.
Update global assemblyinfo with build number
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
$assemblyFile = "$env:APPVEYOR_BUILD_FOLDER\src\GlobalAssemblyInfo.cs" | |
$regex = new-object System.Text.RegularExpressions.Regex ('(AssemblyInformationalVersion(Attribute)?\s*\(\s*\")(.*)(\"\s*\))', | |
[System.Text.RegularExpressions.RegexOptions]::MultiLine) | |
$content = [IO.File]::ReadAllText($assemblyFile) | |
$version = $null | |
$match = $regex.Match($content) | |
if($match.Success) { | |
$version = $match.groups[3].value | |
} | |
# new version | |
$version = "$version.$env:APPVEYOR_BUILD_NUMBER" | |
# update assembly info | |
$content = $regex.Replace($content, '${1}' + $version + '${4}') | |
[IO.File]::WriteAllText($assemblyFile, $content) | |
# update AppVeyor build | |
Update-AppveyorBuild -Version $version |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I totally agree @ma499
@FeodorFitsner do you guys have a kinda usable "AppVeyor-Contrib" repo? Great place to consolidate things like this!