Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Powershell script to "hard" rebuild a Visual Studio solution
cls
ECHO "Hard rebuilding 'Main' solution. Go get some coffee, this is going to take a few minutes ..."
$stopWatch = [system.diagnostics.stopwatch]::startNew()
ECHO "Cleaning solution ..."
devenv C:\Projects\Main.sln /clean
ECHO "Deleting remaining contents in bin folders ..."
C:\scripts\delete_bin_folders.bat
ECHO "Rebuilding solution ..."
devenv C:\Projects\Main.sln /rebuild Debug
$elapsedTime = [string]::Format("{0:0.0}", $stopWatch.Elapsed.TotalMinutes)
Write-Host "Hard rebuilding 'Main' solution done. Operation took" $elapsedTime "minutes. How was your coffee."
#Write-Host "This script took" $elapsedTime "minutes to complete."
set folder="C:\Projects\Main\UI\bin"
cd /d %folder%
for /F "delims=" %%i in ('dir /b') do (rmdir "%%i" /s/q || del "%%i" /s/q)
set folder="C:\Projects\Main\DataAccess\bin"
cd /d %folder%
for /F "delims=" %%i in ('dir /b') do (rmdir "%%i" /s/q || del "%%i" /s/q)
set folder="C:\Projects\Main\Api\bin"
cd /d %folder%
for /F "delims=" %%i in ('dir /b') do (rmdir "%%i" /s/q || del "%%i" /s/q)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment