Categories
Tips Xamarin

Truly clean bin/obj folders in Xamarin

First step of Holy Grail of Clean, Build and Redeploy in Xamarin

In this article we will discuss how to truly delete bin, obj and packages folders in your projects while working on Xamarin. Visual Studio’s micky mouse clean leaves compiled files behind and does not delete them completely. Using this tip folders are deleted completely and if the files are in use it throws an error so you know at least.

For this we will create a PowerShell script file in the root of the source code, usually beside the .sln file.

Step 1:

Open notepad++ or your favourite editor and put copy this one line in there:

Get-ChildItem -inc bin,obj -rec | Remove-Item -rec -force

Step 2:

Save the file as .ps1 and that’s all.

You can execute this from PS, even handier if you use PS for git and other tasks. Or you can try out the new and cool Windows Terminal and setup Oh-My-Posh in it for awesome look and feel, more on that here.

You can also extend this script to include packages folder.

Get-ChildItem -inc bin,obj,packages -rec | Remove-Item -rec -force

That’s all folks, happy coding.