Scripts/UpdateVersion.ps1
# # UpdateVersion.ps1 # function Set-DataverseSolutionVersion { try { $message = "Updating Solution version for $global:devops_SolutionName" Write-Host $message Write-Host "" foreach ($PatchSolution in $PatchQuery.CrmRecords) { $SolutionId = $PatchSolution.solutionid $SolutionName = $PatchSolution.uniquename $SolutionVersion = $PatchSolution.version Write-Host "Patch found:" $SolutionId "-" $SolutionName "-" $SolutionVersion $theVersion = [version]$SolutionVersion $newVersion = "{0}.{1}.{2}.{3}" -f $theVersion.Major, $theVersion.Minor, $theVersion.Build , ($theVersion.Revision + 1) $verUpdated = Set-CrmSolutionVersionNumber -conn $conn -SolutionName $SolutionName -VersionNumber $newVersion $newVersion.ToString() | Set-Content -Path $global:devops_projectLocation\$global:devops_SolutionName\$global:devops_SolutionName.version Write-Host $verUpdated } If (!$PatchQuery.CrmRecords) { #Major.Minor.Build.Revision = TargetProductionDrop.Year+DayofYear.PatchNumber.BuildTime $theVersion = [version]$SolutionVersion $newVersion = "{0}.{1}{2}.{3}.{4}" -f $theVersion.Major, (Get-Date -UFormat %y), (Get-Date -UFormat %j).PadLeft(3, '0'), $theVersion.Build , (Get-Date -UFormat %H%M) $verUpdated = Set-CrmSolutionVersionNumber -conn $conn -SolutionName $SolutionName -VersionNumber $newVersion $newVersion.ToString() | Set-Content -Path $global:devops_projectLocation\$global:devops_SolutionName\$global:devops_SolutionName.version Write-Host $verUpdated } } catch { Write-Host $_ pause } finally { } } |