Skip to content

Commit 79cb6d6

Browse files
author
Evans Aboge (from Dev Box)
committed
Fix trim
1 parent d45f711 commit 79cb6d6

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

.azure-pipelines/ci-build.yml

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,34 @@ steps:
4343
4444
- powershell: |
4545
$content = [XML](Get-Content ./Directory.Build.props)
46-
$version = $content.Project.PropertyGroup.Version
46+
Write-Host "XML loaded, finding version..."
47+
48+
# Handle PropertyGroup as either a single element or array
49+
$version = $null
50+
if ($content.Project.PropertyGroup -is [array]) {
51+
Write-Host "PropertyGroup is an array, checking each entry..."
52+
foreach ($pg in $content.Project.PropertyGroup) {
53+
if ($pg.Version) {
54+
$version = $pg.Version.ToString().Trim()
55+
Write-Host "Found version in PropertyGroup array: $version"
56+
break
57+
}
58+
}
59+
} else {
60+
# Single PropertyGroup
61+
$version = $content.Project.PropertyGroup.Version
62+
if ($version) {
63+
$version = $version.ToString().Trim()
64+
Write-Host "Found version in PropertyGroup: $version"
65+
}
66+
}
67+
68+
if (-not $version) {
69+
Write-Host "##vso[task.logissue type=error]Version not found in Directory.Build.props"
70+
exit 1
71+
}
72+
4773
Write-Host "Version found: $version"
48-
# Set as both an output variable and a regular variable
4974
Write-Host "##vso[task.setvariable variable=version;isoutput=true]$version"
5075
Write-Host "##vso[task.setvariable variable=VERSION]$version"
5176
displayName: 'Get version from csproj'

0 commit comments

Comments
 (0)