Private/Get-CpmfUipsPublisherProps.ps1

function Get-CpmfUipsPublisherProps {
<#
.SYNOPSIS
    Reads a publisher props file (MSBuild-style XML) and returns its Publisher*
    properties as a hashtable.
 
.DESCRIPTION
    The publisher props file is the single source of truth for package identity
    (authors, tags, project URL) and pack-time policy defaults shared across
    repositories. It is plain XML — not an MSBuild project that gets evaluated —
    so every <PropertyGroup> child element is read literally.
 
    The file may contain more than one <PropertyGroup>; all of them are
    flattened into one lookup. Elements with an empty or whitespace-only value
    are dropped, so a caller can distinguish "not set" from "set to something".
 
    Returns an empty hashtable when -Path is empty or not provided.
 
.PARAMETER Path
    Full path to the .props file.
#>

    [CmdletBinding()]
    [OutputType([hashtable])]
    param(
        [string]$Path
    )

    if ([string]::IsNullOrWhiteSpace($Path)) { return @{} }

    if (-not (Test-Path -LiteralPath $Path)) {
        throw "Publisher props file not found: $Path"
    }

    try {
        [xml]$doc = Get-Content -LiteralPath $Path -Raw
    } catch {
        throw "Publisher props file is not valid XML: $Path — $($_.Exception.Message)"
    }

    $props = @{}
    foreach ($node in $doc.SelectNodes('/Project/PropertyGroup/*')) {
        $value = $node.InnerText
        if ([string]::IsNullOrWhiteSpace($value)) { continue }
        $props[$node.LocalName] = $value.Trim()
    }

    Write-Verbose "[PublisherProps] Loaded $($props.Count) properties from $Path"

    return $props
}