DEV Community

Ben Collins
Ben Collins

Posted on

1

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++}

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay