Merge pull request #62 from libiucode/fix/issue-35-windows-manifest-bom
fix: add BOM for Windows component manifest publisher
- 作者
- Shihao Li
- 时间
- 2026/11/11 16:11
- 提交
- b0d7378
这是一个合并提交,下面是和第一个上一提交相比的改动。
fix: add BOM for Windows component manifest publisher
这是一个合并提交,下面是和第一个上一提交相比的改动。
| @@ -1,4 +1,4 @@ | ||
| 1 | 删除:# Records only the files verified in this fixed guest after installation. | |
| 1 | 新增:# Records only the files verified in this fixed guest after installation. | |
| 2 | 2 | param([guid]$VMId,[string]$GUIUserSID,[string]$ManifestJSON) |
| 3 | 3 | $ErrorActionPreference='Stop' |
| 4 | 4 | if ([guid](Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Virtual Machine\Guest\Parameters').VirtualMachineId -ne $VMId -or |
| @@ -70,4 +70,13 @@ if ($retireAt -lt 0 -or $publishAt -le $retireAt) { throw 'Host enrollment can p | ||
| 70 | 70 | $retireAt = $publisher.Body.Extent.Text.LastIndexOf('Complete-CloneSetup $stageBinding') |
| 71 | 71 | $publishAt = $publisher.Body.Extent.Text.IndexOf('[IO.File]::Copy($stageBinding') |
| 72 | 72 | if ($retireAt -lt 0 -or $publishAt -le $retireAt) { throw 'The local host can publish before clone retirement.' } |
| 73 | 新增: | |
| 74 | 新增:$manifestPublisher = Join-Path $PSScriptRoot 'publish-windows-component-manifest.ps1' | |
| 75 | 新增:$manifestBytes = [IO.File]::ReadAllBytes($manifestPublisher) | |
| 76 | 新增:if ($manifestBytes.Length -lt 3 -or $manifestBytes[0] -ne 0xEF -or $manifestBytes[1] -ne 0xBB -or $manifestBytes[2] -ne 0xBF) { | |
| 77 | 新增: throw 'The component manifest publisher must start with a UTF-8 BOM for Windows PowerShell 5.1.' | |
| 78 | 新增:} | |
| 79 | 新增:$parseErrors = $null | |
| 80 | 新增:$null = [Management.Automation.Language.Parser]::ParseFile($manifestPublisher, [ref]$null, [ref]$parseErrors) | |
| 81 | 新增:if ($parseErrors.Count) { throw "The component manifest publisher failed Windows PowerShell parsing: $($parseErrors[0].Message)" } | |
| 73 | 82 | Write-Output 'Passed isolated account XML, locale preservation, build validation, retained credential identity and interrupted retirement recovery.' |