Scrub bin and obj
When you run Clean Project or Clean Solution in VS, it doesn’t delete everything from bin
and obj
; it just removes the artefacts which VS would normally build. So the output from external tools or previous builds might be left alone.
To do a full ‘scrub’ of bin and obj, we have a few good solutions:
Manual - Powershell
You could just add a Powershell script to the root of the Solution directory with this content:
Get-ChildItem -Include bin,obj -Recurse | Remove-Item -Recurse -Force
…and save it as Scrub.ps1
or something. When you run it, this will recursively delete all bin and obj folders anywhere in subdirectories. I’ve been using this solution for a while, as it’s quick to pull the Powershell file across into a new project. But in researching this post, I’ve found another way:
Automatic - Project config
You can add a snippet near the end of your .vbproj
/.csproj
to extend the functionality of ‘Clean’:
<Target Name="Scrub" AfterTargets="Clean">
<RemoveDir Directories="$(TargetDir)" />
<RemoveDir Directories="$(ProjectDir)$(BaseIntermediateOutputPath)" />
</Target>
These two RemoveDir
instructions target bin and obj respectively. This particular directory syntax is for VS 2015+, and I’ve not actually tested it. It’s included here for completeness and as a second opinion :)