From eaa04afb5c7b09e3d09d55d95a48f3acd8648df9 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 22 May 2026 11:21:41 +0200 Subject: [PATCH] fix build parallelo + rimozione sln duplicata --- IOB-WIN-NEXT/IOB-WIN-NEXT.sln | 31 ------------ build_all_par.ps1 | 94 +++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+), 31 deletions(-) delete mode 100644 IOB-WIN-NEXT/IOB-WIN-NEXT.sln create mode 100644 build_all_par.ps1 diff --git a/IOB-WIN-NEXT/IOB-WIN-NEXT.sln b/IOB-WIN-NEXT/IOB-WIN-NEXT.sln deleted file mode 100644 index 2e7483cd..00000000 --- a/IOB-WIN-NEXT/IOB-WIN-NEXT.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.31205.134 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IOB-WIN-NEXT", "IOB-WIN-NEXT.csproj", "{B2ABB009-C046-4F9C-956C-52DCAA9FE5A9}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Debug|x86 = Debug|x86 - Release|Any CPU = Release|Any CPU - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B2ABB009-C046-4F9C-956C-52DCAA9FE5A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B2ABB009-C046-4F9C-956C-52DCAA9FE5A9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B2ABB009-C046-4F9C-956C-52DCAA9FE5A9}.Debug|x86.ActiveCfg = Debug|x86 - {B2ABB009-C046-4F9C-956C-52DCAA9FE5A9}.Debug|x86.Build.0 = Debug|x86 - {B2ABB009-C046-4F9C-956C-52DCAA9FE5A9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B2ABB009-C046-4F9C-956C-52DCAA9FE5A9}.Release|Any CPU.Build.0 = Release|Any CPU - {B2ABB009-C046-4F9C-956C-52DCAA9FE5A9}.Release|x86.ActiveCfg = Release|x86 - {B2ABB009-C046-4F9C-956C-52DCAA9FE5A9}.Release|x86.Build.0 = Release|x86 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {5BF50E92-A90E-4117-812C-2BFC803594DB} - EndGlobalSection -EndGlobal diff --git a/build_all_par.ps1 b/build_all_par.ps1 new file mode 100644 index 00000000..6c109f27 --- /dev/null +++ b/build_all_par.ps1 @@ -0,0 +1,94 @@ +# --- CONFIGURAZIONE --- +$pattern = "IOB-WIN-*.sln" +# Sostituisci questo percorso con il file .csproj del tuo progetto comune condiviso! +$sharedProjectPath = ".\IOB-WIN-FORM\IOB-WIN-FORM.csproj" + +# Cerca tutte le soluzioni +$solutions = Get-ChildItem -Path . -Filter $pattern -Recurse + +if ($solutions.Count -eq 0) { + Write-Host "āš ļø Nessuna soluzione trovata che corrisponde al pattern: $pattern" -ForegroundColor Yellow + Exit +} + +Write-Host "šŸš€ Trovate $($solutions.Count) soluzioni." -ForegroundColor Magenta + +# FASE 1: Compilazione preventiva del progetto comune +if (Test-Path $sharedProjectPath) { + Write-Host "`nšŸ“¦ Fase 1: Compilazione del progetto comune condiviso..." -ForegroundColor Cyan + dotnet build $sharedProjectPath --configuration Debug + if ($LASTEXITCODE -ne 0) { + Write-Host "āŒ Errore critico: Impossibile compilare il progetto comune. Interruzione." -ForegroundColor Red + Exit + } + Write-Host "āœ… Progetto comune pronto." -ForegroundColor Green +} +else { + Write-Host "āš ļø Attenzione: Percorso del progetto comune non trovato nello script ($sharedProjectPath)." -ForegroundColor Yellow + Write-Host "Il parallelismo potrebbe causare conflitti di file." -ForegroundColor Yellow +} + +# FASE 2: Compilazione parallela delle soluzioni senza toccare le dipendenze esterne +Write-Host "`nšŸ› ļø Fase 2: Avvio compilazione parallela delle soluzioni (Max 4)..." -ForegroundColor Magenta +Write-Host "==================================================" -ForegroundColor Magenta + +$results = $solutions | ForEach-Object -Parallel { + $solName = $_.Name + $solPath = $_.FullName + $sharedExists = $using:sharedProjectPath + + # Se abbiamo compilato prima il progetto comune, usiamo --no-dependencies per evitare lock sui file + if ($sharedExists) { + $log = dotnet build $solPath --configuration Debug --no-dependencies 2>&1 + } + else { + $log = dotnet build $solPath --configuration Debug 2>&1 + } + + [PSCustomObject]@{ + Name = $solName + Success = ($LASTEXITCODE -eq 0) + Log = $log + } +} -ThrottleLimit 4 + +# --- ELABORAZIONE DEI RISULTATI --- +$successCount = 0 +$failCount = 0 +$failedSolutions = @() + +foreach ($res in $results) { + if ($res.Success) { + Write-Host "āœ… $($res.Name) compilata con successo!" -ForegroundColor Green + $successCount++ + } + else { + Write-Host "āŒ Errore nella compilazione di $($res.Name)" -ForegroundColor Red + $failCount++ + $failedSolutions += $res.Name + + Write-Host "--- Dettagli Errore per $($res.Name) ---" -ForegroundColor DarkRed + $res.Log | Select-Object -Last 10 | Write-Host -ForegroundColor Gray + Write-Host "---------------------------------------" -ForegroundColor DarkRed + } +} + +$failColor = if ($failCount -gt 0) { "Red" } else { "Gray" } + +# --- RIEPILOGO FINALE --- +Write-Host "`n==================================================" -ForegroundColor Magenta +Write-Host "šŸ Processo di verifica completato!" -ForegroundColor Magenta +Write-Host "==================================================" -ForegroundColor Magenta +Write-Host " Successi: $successCount" -ForegroundColor Green +Write-Host " Falliti: $failCount" -ForegroundColor $failColor + +if ($failCount -gt 0) { + Write-Host "`nāŒ Elenco delle soluzioni fallite:" -ForegroundColor Red + foreach ($failed in $failedSolutions) { + Write-Host " - $failed" -ForegroundColor Red + } +} +else { + Write-Host "`nšŸŽ‰ Ottimo! Tutte le soluzioni sono state verificate con successo." -ForegroundColor Green +} +Write-Host "==================================================" -ForegroundColor Magenta \ No newline at end of file