# Strip the PRI split configuration from a MakePri-generated priconfig.xml. # # `MakePri.exe createconfig` emits a section telling `MakePri.exe new` to # split resource candidates into separate resource packages (resources.language-*.pri, # resources.scale-*.pri, ...), leaving the main resources.pri with default-context # candidates only. A monolithic MSIX package loads nothing but the resources.pri at its # package root, so any split dimension - autoResourcePackage qualifiers (Language, Scale, # DXFeatureLevel, ...) as well as manual resourcePackage entries - would strip its # candidates from the shipped package, e.g. every non-default UI language would silently # fall back to the source language. # # This script therefore removes the whole element. The schema declares it # optional, and leaving an empty one behind would make MakePri warn about a missing # packaging mode. The file is rewritten in place as UTF-8 without BOM. # # Usage (the Windows CI calls it between `MakePri.exe createconfig` and `MakePri.exe new`): # pwsh -NoProfile -ExecutionPolicy Bypass -File strip-priconfig-packaging-node.ps1 -Path priconfig.xml -Verbose [CmdletBinding()] param( # Path to the priconfig.xml generated by `MakePri.exe createconfig`. [Parameter(Mandatory = $true, Position = 0)] [string]$Path ) if (-not (Test-Path -LiteralPath $Path)) { throw "priconfig file not found: $Path" } # priconfig.xml declares no XML namespace, so plain XPath is sufficient here. $document = [System.Xml.XmlDocument]::new() $document.Load($Path) $packaging = $document.SelectSingleNode('/resources/packaging') if ($null -eq $packaging) { Write-Verbose "No element found; the config already yields a single monolithic PRI." } else { # Report every split directive we are about to drop, for build log auditing. foreach ($node in @($packaging.SelectNodes('autoResourcePackage | resourcePackage'))) { $name = $node.GetAttribute('qualifier') if (-not $name) { $name = $node.GetAttribute('name') } Write-Verbose "Dropping split directive <$($node.Name)> '$name'." } [void]$packaging.ParentNode.RemoveChild($packaging) } # Rewrite in place: UTF-8 without BOM (XmlDocument.Save(string) would emit one) and tab # indentation, matching what createconfig itself emits. $settings = [System.Xml.XmlWriterSettings]::new() $settings.Indent = $true $settings.IndentChars = "`t" $settings.Encoding = [System.Text.UTF8Encoding]::new($false) $writer = [System.Xml.XmlWriter]::Create($Path, $settings) try { $document.Save($writer) } finally { $writer.Close() }