ps/Modules/.build/Get-BuildConfigs.ps1
2023-05-30 22:51:22 -07:00

33 lines
833 B
PowerShell

Function Get-BuildConfigs {
<#
.SYNOPSIS
Get the build configs from a single csproj
#>
[CmdletBinding()]
Param(
$csprojPath
)
process {
if (!(Test-Path $csprojPath)) {
Write-Warning "can't test on an empty path [$csprojPath]"
return
}
$returnValues = @()
$xml = [Xml](Get-Content $csprojPath)
$propertyGroups = @($xml.Project.PropertyGroup)
foreach($propertyGroup in $propertyGroups) {
if ($null -ne $propertyGroup.Condition) {
$value = $propertyGroup.Condition.Replace("'",'').Split('==')[-1].Split('|')[0].Trim()
if (!([string]::IsNullOrWhiteSpace($value))) {
$returnValues += $value
}
}
}
return $returnValues
}
}