From 9bacac8f3d2a3d841467c5240fb2623c0e462f96 Mon Sep 17 00:00:00 2001 From: rbalsleyMSFT <53497092+rbalsleyMSFT@users.noreply.github.com> Date: Tue, 10 Mar 2026 17:01:40 -0700 Subject: [PATCH] Fixes working directory handling Ensures build and cleanup processes run from the expected project location. Prevents temporary state files from being created or removed in the wrong folder, which avoids stale markers and cleanup failures when launched from the UI or another directory. --- FFUDevelopment/BuildFFUVM.ps1 | 6 ++++-- FFUDevelopment/BuildFFUVM_UI.ps1 | 14 ++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/FFUDevelopment/BuildFFUVM.ps1 b/FFUDevelopment/BuildFFUVM.ps1 index a640d51..a312c76 100644 --- a/FFUDevelopment/BuildFFUVM.ps1 +++ b/FFUDevelopment/BuildFFUVM.ps1 @@ -5692,7 +5692,8 @@ If (Test-Path -Path "$FFUDevelopmentPath\dirty.txt") { Get-FFUEnvironment } WriteLog 'Creating dirty.txt file' -New-Item -Path .\ -Name "dirty.txt" -ItemType "file" | Out-Null +$dirtyFilePath = Join-Path -Path $FFUDevelopmentPath -ChildPath 'dirty.txt' +New-Item -Path $dirtyFilePath -ItemType "file" | Out-Null # Early CLI prompt for additional FFUs (only if enabled and not provided) if ($BuildUSBDrive -and $CopyAdditionalFFUFiles -and ((-not $AdditionalFFUFiles) -or ($AdditionalFFUFiles.Count -eq 0))) { @@ -7615,7 +7616,8 @@ else { } #Clean up dirty.txt file -Remove-Item -Path .\dirty.txt -Force | out-null +$dirtyFilePath = Join-Path -Path $FFUDevelopmentPath -ChildPath 'dirty.txt' +Remove-Item -Path $dirtyFilePath -Force | out-null # Remove per-run session folder if present $sessionDir = Join-Path $FFUDevelopmentPath '.session' if (Test-Path -Path $sessionDir) { diff --git a/FFUDevelopment/BuildFFUVM_UI.ps1 b/FFUDevelopment/BuildFFUVM_UI.ps1 index 6f3b06c..7cf7144 100644 --- a/FFUDevelopment/BuildFFUVM_UI.ps1 +++ b/FFUDevelopment/BuildFFUVM_UI.ps1 @@ -293,9 +293,10 @@ $script:uiState.Controls.btnRun.Add_Click({ ) $startCleanupParams = @{ - FilePath = $pwshPath - ArgumentList = $cleanupArgs - PassThru = $true + FilePath = $pwshPath + ArgumentList = $cleanupArgs + WorkingDirectory = $ffuDevPath + PassThru = $true } if ($Host.Name -eq 'ConsoleHost') { $startCleanupParams['NoNewWindow'] = $true @@ -455,9 +456,10 @@ $script:uiState.Controls.btnRun.Add_Click({ } $startBuildParams = @{ - FilePath = $pwshPath - ArgumentList = $pwshArgs - PassThru = $true + FilePath = $pwshPath + ArgumentList = $pwshArgs + WorkingDirectory = $config.FFUDevelopmentPath + PassThru = $true } if ($Host.Name -eq 'ConsoleHost') { $startBuildParams['NoNewWindow'] = $true