Utopia-Canteen-System/scripts/clean-build.ps1

40 lines
1.1 KiB
PowerShell

$ErrorActionPreference = "Continue"
Write-Host "Stopping .NET build servers..."
dotnet build-server shutdown
Write-Host "Killing running app/dotnet processes..."
taskkill /F /IM dotnet.exe 2>$null
taskkill /F /IM UtopiaCanteen.Client.exe 2>$null
taskkill /F /IM UtopiaCanteen.BackendService.exe 2>$null
taskkill /F /IM UtopiaCanteenSystem.exe 2>$null
$root = Split-Path -Parent $PSScriptRoot
Set-Location $root
$me = "$env:USERDOMAIN\$env:USERNAME"
$targets = @(
"obj",
"bin",
"UtopiaCanteen.BackendService\obj",
"UtopiaCanteen.BackendService\bin",
"UtopiaCanteen.Client\obj",
"UtopiaCanteen.Client\bin",
"UtopiaCanteen.Backend\obj",
"UtopiaCanteen.Backend\bin",
"UtopiaCanteen.Shared\obj",
"UtopiaCanteen.Shared\bin"
)
foreach ($t in $targets) {
if (Test-Path $t) {
Write-Host "Taking ownership and removing: $t"
takeown /F $t /R /D Y | Out-Null
icacls $t /grant "${me}:(OI)(CI)F" /T /C | Out-Null
attrib -R $t /S /D
Remove-Item -LiteralPath $t -Recurse -Force -ErrorAction SilentlyContinue
}
}
Write-Host "Clean complete."