Skip to content

Instantly share code, notes, and snippets.

@esmitt
Created July 26, 2020 18:06
Show Gist options
  • Save esmitt/44267cffbe6ab71d235d92dc6381efd5 to your computer and use it in GitHub Desktop.
Save esmitt/44267cffbe6ab71d235d92dc6381efd5 to your computer and use it in GitHub Desktop.
A script to clean my C# projects
@echo off
REM Remove files generated by compiler in this directory and all subdirectories.
REM Essential release files are kept.
echo Removing "*.csproj.user" files...
for /f "delims==" %%i in ('dir /b /on /s "%~p0*.csproj.user"') do del "%%i" /f /q
echo.
echo Removing "*.exe.config" files...
for /f "delims==" %%i in ('dir /b /on /s "%~p0*.exe.config"') do del "%%i" /f /q
echo.
echo Removing "*.vshost.exe.config" files...
for /f "delims==" %%i in ('dir /b /on /s "%~p0*.vshost.exe.config"') do del "%%i" /f /q
echo.
echo Removing "*.pdb" files...
for /f "delims==" %%i in ('dir /b /on /s "%~p0*.pdb"') do del "%%i" /f /q
echo.
echo Removing "*.vshost.application" files...
for /f "delims==" %%i in ('dir /b /on /s "%~p0*.vshost.application"') do del "%%i" /f /q
echo.
echo Removing "*.vshost.exe" files...
for /f "delims==" %%i in ('dir /b /on /s "%~p0*.vshost.exe "') do del "%%i" /f /q
echo.
echo Removing "*.vshost.exe.manifest" files...
for /f "delims==" %%i in ('dir /b /on /s "%~p0*.vshost.exe.manifest "') do del "%%i" /f /q
echo.
echo Removing "obj" directory...
rd "%~p0obj" /s /q
echo.
echo Removing "Debug" directories recursively...
for /f "delims==" %%i in ('dir /b /on /s "%~p0*Debug"') do if "%%~ni"=="Debug" rd "%%i" /s /q
echo.
echo Removing "app.publish" directories recursively...
for /f "delims==" %%i in ('dir /b /on /s "%~p0*app.publish"') do rd "%%i" /s /q
echo.
echo Removing "*_mcr" directories recursively...
for /f "delims==" %%i in ('dir /b /on /s "%~p0*_mcr"') do rd "%%i" /s /q
echo.
echo "%~n0.bat" done.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment