|
| 1 | +<# |
| 2 | +.SYNOPSIS |
| 3 | +Clean all the temporary files/folders |
| 4 | +
|
| 5 | +.DESCRIPTION |
| 6 | +Will clean the solution and a set of project directory from temporary files and folder: |
| 7 | +In project directory : |
| 8 | +- temp folder |
| 9 | +- x64 folder |
| 10 | +- bin folder |
| 11 | +- *.vcxproj file |
| 12 | +- *.filters file |
| 13 | +- *.user file |
| 14 | +
|
| 15 | +In solution directory : |
| 16 | +- log.txt file |
| 17 | +- compile_commands.json file |
| 18 | +- .cache folder |
| 19 | +- .vs folder |
| 20 | +- .sln file |
| 21 | +
|
| 22 | +.PARAMETER projectDirs |
| 23 | +An array of directory path that is contains in a string. Each path is separated by a comma. |
| 24 | +
|
| 25 | +.PARAMETER solutionDir |
| 26 | +The solution directory path to clean. |
| 27 | +
|
| 28 | +.EXAMPLE |
| 29 | +This commands will clean tessendorf plugin and sample tessendorf |
| 30 | +.\buildtools\clean.ps1 -projectDirs ".\SampleBasic, .\PluginInteropUnityCUDA, .\Utilities" -solutionDir ".\" |
| 31 | +
|
| 32 | +.NOTES |
| 33 | +File Name : clean.ps1 |
| 34 | +Author : David Algis |
| 35 | +Prerequisite : PowerShell v3 |
| 36 | +Copyright 2023 - Studio Nyx |
| 37 | +#> |
| 38 | +param ( |
| 39 | + [Parameter(Mandatory = $true)] |
| 40 | + [string]$projectDirs, |
| 41 | + [string]$solutionDir |
| 42 | +) |
| 43 | + |
| 44 | +if (-not $projectDirs -or -not $solutionDir) { |
| 45 | + Write-Host "Error: One or more arguments are empty." |
| 46 | + exit 1 |
| 47 | +} |
| 48 | + |
| 49 | +$projectDirArray = $projectDirs -split "," |
| 50 | + |
| 51 | +function CleanProject([string]$projectDir) { |
| 52 | + Write-Host "Clean temporary directory $($projectDir)temp/ and $($projectDir)x64/" |
| 53 | + # $absoluteProjectDir = [System.IO.Path]::GetFullPath($projectDir) |
| 54 | + Remove-Item -Recurse -Force -ErrorAction SilentlyContinue "$($projectDir)x64/" |
| 55 | + Remove-Item -Recurse -Force -ErrorAction SilentlyContinue "$($projectDir)temp/" |
| 56 | + Remove-Item -Recurse -Force -ErrorAction SilentlyContinue "$($projectDir)bin/" |
| 57 | + Get-ChildItem -Path $($projectDir) -Recurse -Filter *.vcxproj | Remove-Item -Force -ErrorAction SilentlyContinue |
| 58 | + Get-ChildItem -Path $($projectDir) -Recurse -Filter *.filters | Remove-Item -Force -ErrorAction SilentlyContinue |
| 59 | + Get-ChildItem -Path $($projectDir) -Recurse -Filter *.user | Remove-Item -Force -ErrorAction SilentlyContinue |
| 60 | +} |
| 61 | + |
| 62 | +# Clean projects |
| 63 | +foreach ($dir in $projectDirArray) { |
| 64 | + Write-Host "Clean project $dir" |
| 65 | + CleanProject -projectDir $dir |
| 66 | +} |
| 67 | + |
| 68 | +# Clean solution |
| 69 | +Write-Host "Clean Solution located at $solutionDir" |
| 70 | +Remove-Item -ErrorAction SilentlyContinue "$solutionDir\log.txt" |
| 71 | +Get-ChildItem -Path $solutionDir -Filter *.sln | Remove-Item -ErrorAction SilentlyContinue |
| 72 | +Remove-Item -ErrorAction SilentlyContinue "$solutionDir\compile_commands.json" |
| 73 | +Remove-Item -Recurse -Force -ErrorAction SilentlyContinue "$solutionDir\.cache" |
| 74 | +Remove-Item -Recurse -Force -ErrorAction SilentlyContinue "$solutionDir\.vs" |
0 commit comments