@@ -227,7 +227,19 @@ $manifest = (Get-Content -Raw $manifestTemplate).
227227 Replace(' @PUBLISHER_DISPLAY_NAME@' , $PublisherDisplayName ).
228228 Replace(' @VERSION@' , $Version ).
229229 Replace(' @ARCH@' , $msixArch )
230- Set-Content - Path (Join-Path $layout ' AppxManifest.xml' ) - Value $manifest - Encoding UTF8
230+ $manifestPath = Join-Path $layout ' AppxManifest.xml'
231+ Set-Content - Path $manifestPath - Value $manifest - Encoding UTF8
232+ # makepri reports a malformed manifest as PRI191 buried mid-scroll in a UTF-16-mangled
233+ # usage dump (first hit: '--' inside an XML comment, which the XML spec forbids).
234+ # Validate here so the failure is one readable line instead.
235+ try {
236+ $probe = New-Object System.Xml.XmlDocument
237+ $probe.LoadXml ((Get-Content - Raw $manifestPath ))
238+ }
239+ catch {
240+ $reason = if ($_.Exception.InnerException ) { $_.Exception.InnerException.Message } else { $_.Exception.Message }
241+ throw " Substituted AppxManifest.xml is not well-formed XML: $reason "
242+ }
231243
232244# --- index resources (resources.pri) -----------------------------------------
233245# Without this, Windows ignores the scale/targetsize/unplated qualifier files and the
@@ -236,7 +248,7 @@ New-Item -ItemType Directory -Force -Path $OutDir | Out-Null
236248$priConfig = Join-Path $OutDir ' priconfig.xml'
237249& $makepri createconfig / cf $priConfig / dq en- US / o
238250if ($LASTEXITCODE -ne 0 ) { throw " makepri createconfig failed ($LASTEXITCODE )." }
239- & $makepri new / pr $layout / cf $priConfig / mn ( Join-Path $layout ' AppxManifest.xml ' ) / of (Join-Path $layout ' resources.pri' ) / o
251+ & $makepri new / pr $layout / cf $priConfig / mn $manifestPath / of (Join-Path $layout ' resources.pri' ) / o
240252if ($LASTEXITCODE -ne 0 ) { throw " makepri new failed ($LASTEXITCODE )." }
241253
242254# --- pack --------------------------------------------------------------------
0 commit comments