mirror of
https://github.com/tribufu/ServerManagers
synced 2026-05-18 09:35:48 +00:00
pipeline file changes
This commit is contained in:
parent
4040cab65d
commit
c66d94fea4
1 changed files with 33 additions and 0 deletions
|
|
@ -20,4 +20,37 @@ steps:
|
||||||
[int]$PatternExpectedVersionNumbers = 4
|
[int]$PatternExpectedVersionNumbers = 4
|
||||||
[int]$VersionNumbersInVersion = 4
|
[int]$VersionNumbersInVersion = 4
|
||||||
|
|
||||||
|
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
|
pwsh: true
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue