Files
Mapo-IOB-WIN/build_one.ps1
T
2026-05-22 11:42:46 +02:00

56 lines
2.4 KiB
PowerShell

# --- CONFIGURAZIONE DI TEST ---
# Inserisci qui il percorso esatto del file .sln che vuoi testare
$solutionPath = "IOB-WIN-NEXT.sln"
# $solutionPath = "IOB-WIN-MITSUBISHI.sln"
# --- TROVA MSBUILD (Versione Corretta per installazioni multiple) ---
$vsPaths = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -version "[17.0,18.0)" -products * -requires Microsoft.Component.MSBuild -property installationPath
if (-not $vsPaths) {
Write-Host "❌ Impossibile trovare Visual Studio 2022!" -ForegroundColor Red
Exit
}
# Prendiamo SOLO LA PRIMA installazione trovata per evitare stringhe doppie
$firstVsPath = $vsPaths[0]
$msbuildPath = Join-Path $firstVsPath "MSBuild\Current\Bin\MSBuild.exe"
if (-not (Test-Path $solutionPath)) {
Write-Host "❌ Il file della soluzione specificato non esiste: $solutionPath" -ForegroundColor Red
Exit
}
Write-Host "🎯 Soluzione sotto test: $solutionPath" -ForegroundColor Cyan
Write-Host "🎯 Usando MSBuild: $msbuildPath" -ForegroundColor Gray
Write-Host "--------------------------------------------------" -ForegroundColor Gray
# 1. NuGet Restore
Write-Host "📦 [1/3] Ripristino pacchetti NuGet in corso..." -ForegroundColor Yellow
& $msbuildPath $solutionPath /t:Restore /v:m
if ($LASTEXITCODE -ne 0) { Write-Host "❌ Fallito il ripristino NuGet!" -ForegroundColor Red; Exit }
# 2. Clean
Write-Host "🧹 [2/3] Pulizia soluzione (Clean)..." -ForegroundColor Yellow
& $msbuildPath $solutionPath /t:Clean /v:m /p:Configuration=Debug
# 3. Build reale
Write-Host "🚀 [3/3] Compilazione (Build)..." -ForegroundColor Yellow
Write-Host "==================================================" -ForegroundColor DarkGray
# Eseguiamo catturando l'output
& $msbuildPath $solutionPath /t:Build /p:Configuration=Debug /v:normal
# Controllo finale REALE sul codice di uscita dell'ultimo comando eseguito
$finalResult = $LASTEXITCODE
if ($finalResult -eq 0) {
Write-Host "`n==================================================" -ForegroundColor Green
Write-Host "✅ COMPILAZIONE AVVENUTA CON SUCCESSO!" -ForegroundColor Green
Write-Host "==================================================" -ForegroundColor Green
}
else {
Write-Host "`n==================================================" -ForegroundColor Red
Write-Host "❌ COMPILAZIONE FALLITA!" -ForegroundColor Red
Write-Host "==================================================" -ForegroundColor Red
}