|
60 | 60 | .PARAMETER SkipRestore |
61 | 61 | Skips restoring NuGet packages |
62 | 62 |
|
| 63 | +.PARAMETER Clean |
| 64 | + If set, removes the repository-level Output/ and Obj/ directories before building. |
| 65 | + Useful to clear stale artifacts that can cause assembly version mismatches. |
| 66 | +
|
63 | 67 | .PARAMETER SkipNative |
64 | 68 | Skips building native C++ components. Use this for faster iterations when making purely managed code changes. |
65 | 69 |
|
|
134 | 138 | .\build.ps1 -RunTests |
135 | 139 | Builds Debug x64 including test projects and runs all tests. |
136 | 140 |
|
| 141 | +.EXAMPLE |
| 142 | + .\build.ps1 -Clean |
| 143 | + Removes Output/ and Obj/ first, then builds Debug x64. |
| 144 | +
|
137 | 145 | .EXAMPLE |
138 | 146 | .\build.ps1 -Serial -Verbosity detailed |
139 | 147 | Builds Debug x64 serially with detailed logging. |
@@ -163,6 +171,7 @@ param( |
163 | 171 | [string]$LogFile, |
164 | 172 | [int]$TailLines, |
165 | 173 | [switch]$SkipRestore, |
| 174 | + [switch]$Clean, |
166 | 175 | [switch]$SkipNative, |
167 | 176 | [switch]$SkipNativeTests, |
168 | 177 | [switch]$SkipManagedTests, |
@@ -391,6 +400,26 @@ try { |
391 | 400 | $fwTasksDropPath = Join-Path $PSScriptRoot "BuildTools/FwBuildTasks/$Configuration/FwBuildTasks.dll" |
392 | 401 |
|
393 | 402 | Invoke-WithFileLockRetry -Context "FieldWorks build" -IncludeOmniSharp -RepoRoot $PSScriptRoot -Action { |
| 403 | + if ($Clean) { |
| 404 | + if ($InstallerOnly) { |
| 405 | + throw "-Clean cannot be used with -InstallerOnly because installer-only builds require existing Output\\<Configuration> artifacts." |
| 406 | + } |
| 407 | + |
| 408 | + Write-Host "Cleaning build artifacts (Output/, Obj/) ..." -ForegroundColor Cyan |
| 409 | + $pathsToClean = @( |
| 410 | + (Join-Path $PSScriptRoot "Output"), |
| 411 | + (Join-Path $PSScriptRoot "Obj") |
| 412 | + ) |
| 413 | + |
| 414 | + foreach ($path in $pathsToClean) { |
| 415 | + if (Test-Path $path) { |
| 416 | + Remove-Item -Path $path -Recurse -Force -ErrorAction SilentlyContinue |
| 417 | + } |
| 418 | + } |
| 419 | + |
| 420 | + Write-Host "Clean complete." -ForegroundColor Green |
| 421 | + } |
| 422 | + |
394 | 423 | # Initialize Visual Studio Developer environment |
395 | 424 | Initialize-VsDevEnvironment |
396 | 425 | Test-CvtresCompatibility |
|
0 commit comments