Skip to content

Instantly share code, notes, and snippets.

@FeodorFitsner
Created January 6, 2016 23:04
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FeodorFitsner/82dad08650d72268e48d to your computer and use it in GitHub Desktop.
Save FeodorFitsner/82dad08650d72268e48d to your computer and use it in GitHub Desktop.
Update global assemblyinfo with build number
$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
@ma499
Copy link

ma499 commented May 19, 2016

It would be really good to have a library of these type of steps that we can easily pull into each project's appveyor.yml

@ericnewton76
Copy link

I totally agree @ma499

@FeodorFitsner do you guys have a kinda usable "AppVeyor-Contrib" repo? Great place to consolidate things like this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment