Skip to content

Instantly share code, notes, and snippets.

@scottdurow
Created April 28, 2021 21:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottdurow/fe844a012c388f2e3e8bafdf4a2d897d to your computer and use it in GitHub Desktop.
Save scottdurow/fe844a012c388f2e3e8bafdf4a2d897d to your computer and use it in GitHub Desktop.
Update Solution Version PowerShell
$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"
@scottdurow
Copy link
Author

Easier to read imho

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