DEV Community

Ben Collins
Ben Collins

Posted on

Running view compilation with a progress bar

I ran into a build issue where view compilation failed on CI, but I didn't catch it because views aren't normally precompiled in developer builds. Here's what I wrote to check things out without having to do it manually:

$webdirs = gci -rec -Directory -Exclude "*node_modules*" `
  |? { ((Test-Path "$($_.FullName)\*.csproj") -eq $True) `
       -and ((Test-Path "$($_.FullName)\web.config") -eq $True) }

$webdirs |% {$idx = 0}{$pct = $idx/$projDirs.Length; `
  Write-Progress -Activity "Building Views" `
                 -Status ("{0:P}" -f $pct) `
                 -PercentComplete ($pct*100) `
                 -CurrentOperation "aspnet_compiler -v temp -p $($_.FullName)"; `
  aspnet_compiler -v temp -p $_.FullName; $idx++}

Top comments (0)