From 4040cab65dc3dd268282988622690314b1a37450 Mon Sep 17 00:00:00 2001 From: Brett Hewitson Date: Thu, 29 Dec 2022 15:17:21 +1000 Subject: [PATCH] pipeline file changes --- ...mantic-versioning-to-assembyinfo-files.yml | 72 ------------------- 1 file changed, 72 deletions(-) diff --git a/.azure/pipelines/apply-semantic-versioning-to-assembyinfo-files.yml b/.azure/pipelines/apply-semantic-versioning-to-assembyinfo-files.yml index 6c0e053d..ea47b345 100644 --- a/.azure/pipelines/apply-semantic-versioning-to-assembyinfo-files.yml +++ b/.azure/pipelines/apply-semantic-versioning-to-assembyinfo-files.yml @@ -20,76 +20,4 @@ steps: [int]$PatternExpectedVersionNumbers = 4 [int]$VersionNumbersInVersion = 4 - Function Replace-Version($content, $version, $attribute) { - $exitFunction = $false - $content | % { - if ($_ -match 'exclude from semantic versioning') { - Write-Host " * Skipping $attribute due to exclude" - $exitFunction = $true - } - - if ($_ -match 'include semantic versioning' -and $_ -notmatch "include semantic versioning - $ApplicationName") { - Write-Host " * Skipping $attribute due to include not matching" - $exitFunction = $true - } - } - - if ($exitFunction) { - return $content - } - - $versionAttribute = "[assembly: $attribute(""$version"")]" - $Pattern = "\[assembly: $attribute\("".*""\)\]" - $versionReplaced = $false - - $content = $content | % { - if ($_ -match $Pattern) { - $versionReplaced = $true - $_ = $_ -replace [regex]::Escape($Matches[0]),$versionAttribute - Write-Host " * Replaced $($Matches[0]) with $versionAttribute" - } - $_ - } - - if (-not $versionReplaced) { - $content += [Environment]::NewLine + $versionAttribute - Write-Host " * Added $versionAttribute to end of content" - } - - return $content - } - - Function Get-VersionString($numberOfVersions, $extractedBuildNumbers) { - return [string]::Join('.',($extractedBuildNumbers | select -First ($numberOfVersions))) - } - - if ($BuildNumber -match $Pattern -ne $true) { - Write-Host "Could not extract a version from [$BuildNumber] using pattern [$Pattern]" - exit 2 - } - - # Set version variables - $extractedBuildNumbers = @($Matches[0].Split(([char[]]$PatternSplitCharacters))) - if ($extractedBuildNumbers.Length -ne $PatternExpectedVersionNumbers) { - Write-Host "The extracted build number $($Matches[0]) does not contain the expected $PatternExpectedVersionNumbers elements" - exit 2 - } - - $version = Get-VersionString -numberOfVersions $VersionNumbersInVersion -extractedBuildNumbers $extractedBuildNumbers - $fileVersion = Get-VersionString -numberOfVersions $VersionNumbersInVersion -extractedBuildNumbers $extractedBuildNumbers - Write-Host "Using version $version and file version $fileVersion" - - # iterate the search path (and sub directories) looking for files that match the search filter - Get-ChildItem -Path $PathToSearch -Filter $SearchFilter -Recurse | % { - Write-Host " -> Checking $($_.FullName)" - - # remove the read-only bit on the file - Set-ItemProperty $_.FullName -name IsReadOnly -value $false - - # run the regex replace - $content = Get-Content $_.FullName - $content = Replace-Version -content $content -version $version -attribute 'AssemblyVersion' - $content = Replace-Version -content $content -version $fileVersion -attribute 'AssemblyFileVersion' - $content | Set-Content $_.FullName -Encoding UTF8 - } pwsh: true