-
-
Save scottdurow/fe844a012c388f2e3e8bafdf4a2d897d to your computer and use it in GitHub Desktop.
Update Solution Version PowerShell
This file contains 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
$VersionRegex = "\d+\.\d+\.(\d+\.\d+)" | |
# Apply the version to the solution | |
$NewVersion = "1.0.$($VersionData[0].Groups[1])" | |
Write-Output "Solution Version: $NewVersion" | |
$VersionRegexProject = "<Version>\d+\.\d+.\d+.\d+</Version>" | |
$file = "$($Env:BUILD_SOURCESDIRECTORY)\SolutionPackage\package\Other\Solution.xml" | |
Write-Output $file | |
$filecontent = Get-Content($file) | |
attrib $file -r | |
$filecontent -replace $VersionRegexProject, "<Version>$NewVersion</Version>" | Out-File $file -Encoding ascii | |
Write-Verbose "$($file) - Solution version applied" | |
# Apply the version to PCF Manifest | |
$NewVersion = "0.$($VersionData[0].Groups[1])" | |
Write-Output "PCF Version: $NewVersion" | |
$VersionRegexProject = "version=""\d+\.\d+\.\d+""" | |
$file = "$($Env:BUILD_SOURCESDIRECTORY)\PCF\ControlManifest.Input.xml" | |
Write-Output $file | |
$filecontent = Get-Content($file) | |
attrib $file -r | |
$filecontent -replace $VersionRegexProject, "version=""$NewVersion""" | Out-File $file -Encoding ascii | |
Write-Verbose "$($file) - PCF version applied" | |
# Apply the version to the assembly property files | |
$NewVersion = "1.0.$($VersionData[0].Groups[1])" | |
$PSDefaultParameterValues['Out-File:Encoding'] = 'utf8' | |
Write-Output "Plugin Vesion: $NewVersion" | |
$VersionRegexProject = "AssemblyVersion\(""\d+\.\d+\.\d+\.\d+""\)" | |
$file = "$($Env:BUILD_SOURCESDIRECTORY)\Plugins\Properties\AssemblyInfo.cs" | |
Write "$($file)" | |
$filecontent = Get-Content($file) | |
attrib $file -r | |
$filecontent -replace $VersionRegexProject, "AssemblyVersion(""$NewVersion"")" | Out-File $file | |
Write-Verbose "$($file) - Plugin version applied" |
I am guessing because you’ve named your build using year month day format? I use semantic versioning -
I didn't touch it, so yes? Any benefit to your versioning?
Easier to read imho
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I got errors with this. Ended up adding some additional logging and error checking, and parametrizing the solution and plugin path. Haven't gotten around to needing the PCF yet, so that's also commented out. Also not sure how to handle the build number. 1.0.20210429.10 is invalid because '20210429' is too big for the plugin to build, so I've substringed it to 'YYMM'.