Fix resource xml node errors

This commit is contained in:
Howard Wu 2023-03-27 17:53:24 +08:00
parent 3b39690fef
commit d01fdc3951
2 changed files with 19 additions and 14 deletions

View File

@ -126,6 +126,7 @@ If (($null -Ne $Installed) -And (-Not ($Installed.IsDevelopmentMode))) {
Write-Warning "There is already one installed WSA. Please uninstall it first.`r`nPress y to uninstall existing WSA or press any key to exit" Write-Warning "There is already one installed WSA. Please uninstall it first.`r`nPress y to uninstall existing WSA or press any key to exit"
$key = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown') $key = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
If ("y" -Eq $key.Character) { If ("y" -Eq $key.Character) {
Clear-Host
Remove-AppxPackage -Package $Installed.PackageFullName Remove-AppxPackage -Package $Installed.PackageFullName
} }
Else { Else {
@ -144,6 +145,7 @@ ElseIf ($null -Ne $Installed) {
Clear-Host Clear-Host
Write-Error "Failed to update.`r`nPress any key to uninstall existing installation while preserving user data.`r`nTake in mind that this will remove the Android apps' icon from the start menu.`r`nIf you want to cancel, close this window now." Write-Error "Failed to update.`r`nPress any key to uninstall existing installation while preserving user data.`r`nTake in mind that this will remove the Android apps' icon from the start menu.`r`nIf you want to cancel, close this window now."
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown') $null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
Clear-Host
Remove-AppxPackage -PreserveApplicationData -Package $Installed.PackageFullName Remove-AppxPackage -PreserveApplicationData -Package $Installed.PackageFullName
Add-AppxPackage -ForceApplicationShutdown -ForceUpdateFromAnyVersion -Register .\AppxManifest.xml Add-AppxPackage -ForceApplicationShutdown -ForceUpdateFromAnyVersion -Register .\AppxManifest.xml
If ($?) { If ($?) {

View File

@ -25,32 +25,35 @@ If ((Test-Path -Path "pri") -Eq $true -And (Test-Path -Path "xml") -Eq $true) {
If ($ProcNew.ExitCode -Ne 0) { If ($ProcNew.ExitCode -Ne 0) {
Write-Warning "Failed to merge resources from pris`r`nTrying to dump pris to priinfo...." Write-Warning "Failed to merge resources from pris`r`nTrying to dump pris to priinfo...."
New-Item -Path "." -Name "priinfo" -ItemType "directory" New-Item -Path "." -Name "priinfo" -ItemType "directory"
$Processes = ForEach ($Item in Get-Item ".\pri\*" -Include "*.pri") { Clear-Host
$Name = $Item.Name $i = 0
$RelativePath = $Item | Resolve-Path -Relative $PriItem = Get-Item ".\pri\*" -Include "*.pri"
Write-Host "Dumping $Name....`r`n" Write-Host "Dumping resources...."
Start-Process -PassThru -WindowStyle Hidden makepri.exe -Args "dump /if $RelativePath /o /es .\pri\resources.pri /of .\priinfo\$Name.xml /dt detailed" $Processes = ForEach ($Item in $PriItem) {
Start-Process -PassThru -WindowStyle Hidden makepri.exe -Args "dump /if $($Item | Resolve-Path -Relative) /o /es .\pri\resources.pri /of .\priinfo\$($Item.Name).xml /dt detailed"
$i = $i + 1
$Completed = ($i / $PriItem.count) * 100
Write-Progress -Activity "Dumping resources" -Status "Dumping $($Item.Name):" -PercentComplete $Completed
} }
Write-Host "Dumping resources....`r`n"
$Processes | Wait-Process $Processes | Wait-Process
Write-Host "Creating pri from dumps....`r`n" Write-Progress -Activity "Dumping resources" -Status "Ready" -Completed
Clear-Host
Write-Host "Creating pri from dumps...."
$ProcNewFromDump = Start-Process -PassThru -WindowStyle Hidden makepri.exe -Args "new /pr .\priinfo /cf .\xml\priconfig.xml /of .\resources.pri /mn $AppxManifestFile /o" $ProcNewFromDump = Start-Process -PassThru -WindowStyle Hidden makepri.exe -Args "new /pr .\priinfo /cf .\xml\priconfig.xml /of .\resources.pri /mn $AppxManifestFile /o"
$ProcNewFromDump.WaitForExit() $ProcNewFromDump.WaitForExit()
Remove-Item 'priinfo' -Recurse Remove-Item 'priinfo' -Recurse
If ($ProcNewFromDump.ExitCode -Ne 0) { If ($ProcNewFromDump.ExitCode -Ne 0) {
Write-Warning "Failed to create resources from priinfos`r`n" Write-Warning "Failed to create resources from priinfos"
exit 1 exit 1
} }
} }
$ProjectXml = [xml](Get-Content $AppxManifestFile) $ProjectXml = [xml](Get-Content $AppxManifestFile)
$ProjectResources = $ProjectXml.Package.Resources; $ProjectResources = $ProjectXml.Package.Resources;
$Item = Get-Item .\xml\* -Exclude "priconfig.xml" -Include "*.xml" $(Get-Item .\xml\* -Exclude "priconfig.xml" -Include "*.xml") | ForEach-Object {
$Item | ForEach-Object { $($([xml](Get-Content $_)).Package.Resources.Resource) | ForEach-Object {
$Xml = [xml](Get-Content $_) $ProjectResources.AppendChild($($ProjectXml.ImportNode($_, $true)))
$Resource = $Xml.Package.Resources.Resource }
$newNode = $ProjectXml.ImportNode($Resource, $true)
$ProjectResources.AppendChild($newNode)
} }
$ProjectXml.Save($AppxManifestFile) $ProjectXml.Save($AppxManifestFile)
Remove-Item 'pri' -Recurse Remove-Item 'pri' -Recurse