Skip to content

Commit

Permalink
Update SandboxTest.ps1 to use UTF-8 on winget validate manifest (micr…
Browse files Browse the repository at this point in the history
  • Loading branch information
Utesgui authored Feb 4, 2025
1 parent a79a85c commit 71b9ee5
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions Tools/SandboxTest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,19 @@ if (!$SkipManifestValidation -and ![String]::IsNullOrWhiteSpace($Manifest)) {
Invoke-CleanExit -ExitCode 3
}
Write-Information "--> Validating Manifest"
$validateCommandOutput = winget.exe validate $Manifest
switch ($LASTEXITCODE) {
$validateCommandOutput =
& {
# Store current output encoding setting
$prevOutEnc = [Console]::OutputEncoding
# Set [Console]::OutputEncoding to UTF-8 since winget uses UTF-8 for output
[Console]::OutputEncoding = $OutputEncoding = [System.Text.Utf8Encoding]::new()

winget.exe validate $Manifest

# Reset the encoding to the previous values
[Console]::OutputEncoding = $prevOutEnc
}
switch ($LASTEXITCODE) {
'-1978335191' {
($validateCommandOutput | Select-Object -Skip 1 -SkipLast 1) | Write-Information # Skip the first line and the empty last line
Write-Error -Category ParserError 'Manifest validation failed' -ErrorAction Continue
Expand Down

0 comments on commit 71b9ee5

Please sign in to comment.