Skip to content

Commit 89ac378

Browse files
committed
fix: 乱码
1 parent 31ed580 commit 89ac378

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

Packaging/Build.ps1

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,13 +171,26 @@ if ($Mode -eq "Canary") {
171171
}
172172
}
173173

174-
$xml.Save($ManifestPath)
174+
# 使用 XmlWriter 设置编码,防止乱码
175+
$settings = New-Object System.Xml.XmlWriterSettings
176+
$settings.Indent = $true
177+
$settings.Encoding = [System.Text.Encoding]::UTF8
178+
$writer = [System.Xml.XmlWriter]::Create($ManifestPath, $settings)
179+
$xml.Save($writer)
180+
$writer.Close()
175181
} else {
176182
# Release 模式也要更新 Version
177183
$ManifestPath = "$PackDir\AppxManifest.xml"
178184
[xml]$xml = Get-Content $ManifestPath
179185
$xml.Package.Identity.Version = $BuildVersion
180-
$xml.Save($ManifestPath)
186+
187+
# 同样使用 XmlWriter
188+
$settings = New-Object System.Xml.XmlWriterSettings
189+
$settings.Indent = $true
190+
$settings.Encoding = [System.Text.Encoding]::UTF8
191+
$writer = [System.Xml.XmlWriter]::Create($ManifestPath, $settings)
192+
$xml.Save($writer)
193+
$writer.Close()
181194
}
182195

183196
# ==========================================

0 commit comments

Comments
 (0)