corp-app/clean-and-build.ps1

85 lines
2.8 KiB
PowerShell

# Скрипт для очистки и сборки CORP-MAUI проекта
Write-Host "=====================================" -ForegroundColor Cyan
Write-Host " CORP-MAUI Clean & Build Script" -ForegroundColor Cyan
Write-Host "=====================================" -ForegroundColor Cyan
Write-Host ""
# Переходим в директорию скрипта
$scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Path
Set-Location $scriptPath
# Завершаем все процессы CORP-MAUI
Write-Host "Stopping CORP-MAUI processes..." -ForegroundColor Yellow
$processes = Get-Process | Where-Object {
$_.ProcessName -like "*CORP-MAUI*" -or
$_.ProcessName -like "*CORP_MAUI*"
}
if ($processes) {
$processes | ForEach-Object {
Write-Host " Stopping process: $($_.ProcessName) (PID: $($_.Id))" -ForegroundColor Gray
Stop-Process -Id $_.Id -Force -ErrorAction SilentlyContinue
}
Start-Sleep -Seconds 2
Write-Host " Processes stopped." -ForegroundColor Green
} else {
Write-Host " No running processes found." -ForegroundColor Green
}
Write-Host ""
# Очищаем проект через dotnet
Write-Host "Cleaning project with 'dotnet clean'..." -ForegroundColor Yellow
dotnet clean --verbosity quiet
Write-Host " Done." -ForegroundColor Green
Write-Host ""
# Удаляем папки bin и obj
Write-Host "Deleting bin and obj folders..." -ForegroundColor Yellow
$binPath = Join-Path $scriptPath "CORP-MAUI\bin"
$objPath = Join-Path $scriptPath "CORP-MAUI\obj"
if (Test-Path $binPath) {
Remove-Item -Path $binPath -Recurse -Force -ErrorAction SilentlyContinue
Write-Host " Deleted: $binPath" -ForegroundColor Gray
}
if (Test-Path $objPath) {
Remove-Item -Path $objPath -Recurse -Force -ErrorAction SilentlyContinue
Write-Host " Deleted: $objPath" -ForegroundColor Gray
}
Write-Host " Done." -ForegroundColor Green
Write-Host ""
# Собираем проект
Write-Host "Building project..." -ForegroundColor Yellow
Write-Host ""
$buildOutput = dotnet build --no-restore 2>&1
# Проверяем результат
if ($LASTEXITCODE -eq 0) {
Write-Host ""
Write-Host "=====================================" -ForegroundColor Green
Write-Host " BUILD SUCCESSFUL!" -ForegroundColor Green
Write-Host "=====================================" -ForegroundColor Green
} else {
Write-Host ""
Write-Host "=====================================" -ForegroundColor Red
Write-Host " BUILD FAILED!" -ForegroundColor Red
Write-Host "=====================================" -ForegroundColor Red
Write-Host ""
Write-Host "Build output:" -ForegroundColor Yellow
Write-Host $buildOutput
}
Write-Host ""
Write-Host "Press any key to exit..."
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")