fix(winpe): provision USB partitions with storage cmdlets#166
Conversation
9ac2b64 to
de02668
Compare
de02668 to
c1fcc9f
Compare
c1fcc9f to
20a25e4
Compare
| new WinPeBuildArtifact | ||
| { | ||
| WorkingDirectoryPath = workspace.RootPath, | ||
| MediaDirectoryPath = Path.Combine(workspace.RootPath, "media"), |
| new WinPeBuildArtifact | ||
| { | ||
| WorkingDirectoryPath = workspace.RootPath, | ||
| MediaDirectoryPath = Path.Combine(workspace.RootPath, "media"), |
20a25e4 to
f38c4d9
Compare
f38c4d9 to
a26a1d6
Compare
There was a problem hiding this comment.
Pull request overview
Fixes a USB media creation failure (#165) caused by DiskPart losing volume focus between select volume and format. The provisioning step now invokes a PowerShell Storage cmdlet script (passed as an -EncodedCommand) that clears, initializes, partitions, and formats the BOOT and cache volumes by explicit drive letter. The script emits Foundry-prefixed progress/verbose markers that the service forwards through the existing IProgress<WinPeMediaProgress> pipeline (extended with a new LogDetail field), and adds localized substep strings (en-US, fr-FR) plus regression tests.
Changes:
- Replace DiskPart-based
BuildDiskPartScriptwithBuildPowerShellProvisioningScript, executed viaIWinPeProcessOutputRunnerso progress/verbose markers can be streamed to the UI. - Extend
WinPeMediaProgresswithLogDetailand surface it inStartMediaViewModellogging and new localized status strings. - Update unit tests to cover the new script generation, output forwarding, and confirm DiskPart is no longer invoked.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/Foundry.Core/Services/WinPe/WinPeUsbMediaService.cs | Switch USB partition/format to PowerShell Storage cmdlets, stream progress/verbose markers, update failure diagnostics. |
| src/Foundry.Core/Services/WinPe/WinPeMediaProgress.cs | Add LogDetail property for forwarded verbose diagnostics. |
| src/Foundry/ViewModels/StartMediaViewModel.cs | Log LogDetail and map new provisioning substep statuses to resource keys. |
| src/Foundry/Strings/en-US/Resources.resw | Add English strings for the new USB provisioning substeps. |
| src/Foundry/Strings/fr-FR/Resources.resw | Add French translations for the new USB provisioning substeps. |
| src/Foundry.Core.Tests/WinPe/WinPeUsbMediaServiceTests.cs | Replace DiskPart-script tests with PowerShell-script tests; add streaming/output forwarding regression coverage. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "Clear-Disk -Number $diskNumber -RemoveData -RemoveOEM -Confirm:$false -ErrorAction Stop", | ||
| "Update-HostStorageCache -ErrorAction SilentlyContinue", | ||
| "Write-FoundryUsbVerbose 'USB partition table cleared and host storage cache refreshed.'", |
Summary
Fix USB boot media provisioning by replacing the DiskPart partitioning script with PowerShell Storage cmdlets and restoring detailed provisioning diagnostics in the media logs.
Fixes #165.
Reason
DiskPart can create a partition without reliably keeping a usable volume selected on fresh or inconsistent removable media. The original issue failed after
select volume=<letter>, and the later USB test showed the same class of failure whenformatran without an explicitly selected volume.Using Storage cmdlets lets Foundry create partitions with explicit drive letters and format those volumes directly by drive letter, without depending on DiskPart focus state. The Storage cmdlets are quiet on success, so the script emits Foundry progress markers plus clean provisioning diagnostics that are streamed back into
Foundry.logthrough the existing media progress pipeline. Native PowerShell verbose/progress streams are not forwarded because Windows PowerShell 5.1 serializes them as CLIXML in redirected streams.Main changes
diskpart.exewith an encoded PowerShell Storage script.LogDetail, while keeping the visible operation status readable.Testing notes
diskpart.exe.dotnet test src\Foundry.Core.Tests\Foundry.Core.Tests.csproj --filter "FullyQualifiedName~WinPeUsbMediaServiceTests" --logger "console;verbosity=normal": 23 passed.dotnet build src\Foundry\Foundry.csproj --no-restore: succeeded, 0 warnings, 0 errors.dotnet test src\Foundry.Core.Tests\Foundry.Core.Tests.csproj --logger "console;verbosity=normal": 178 passed.git diff --check: clean, with Windows line-ending warnings only.