Skip to content

Commit ba7b74b

Browse files
committed
Fix set-version script
On Powershell 5.1.16299.98 it no longer ran as before. Seems the xml deserialization changed behavior so we get an array when reading Version node.
1 parent 725585e commit ba7b74b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Build/set-version.psm1

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@ function Set-ProjectVersionAndCommit(
3131
Write-Host "New tag: $newSemVer"
3232
}
3333
catch {
34-
$ex = $Error[0]
35-
$err = Resolve-Error
36-
Write-Error "ERROR: Failed to update build parameters from .csproj file: `n---`n$err"
34+
$err = $PSItem.Exception
35+
Write-Error "ERROR: Failed to update build parameters from .csproj file: `n---`n$err`n---`n$($PSItem.ScriptStackTrace)"
3736
exit 1
3837
}
3938
}
@@ -44,7 +43,7 @@ function Set-ProjectVersion([string] $projectPath, [string] $setVersion) {
4443
Write-Host "$projectPath -> $setVersion"
4544

4645
# Update <Version> property
47-
$projectXml.Project.PropertyGroup.Version = $setVersion
46+
$projectXml.Project.PropertyGroup.Version[0] = $setVersion
4847
$projectXml.Save($projectPath)
4948
}
5049

@@ -112,7 +111,8 @@ function Get-ProjectVersionAndSuffix([xml] $projectXml) {
112111

113112
# Split "1.2.3-alpha" into ["1.2.3", "alpha"]
114113
# Split "1.2.3" into ["1.2.3"]
115-
$oldSemVer = $projectXml.Project.PropertyGroup.Version
114+
$oldSemVer = $($projectXml.Project.PropertyGroup.Version)[0]
115+
116116
$oldSemVerParts = $oldSemVer.Split('-')
117117
$oldVersion = $null
118118
if (-not [Version]::TryParse($oldSemVerParts[0], [ref] $oldVersion)) { throw "Unable to parse old version." }

0 commit comments

Comments
 (0)