DEV Community

Cover image for Clean up space on a .NET Developer Machine
Emanuele Bartolesi
Emanuele Bartolesi

Posted on

Clean up space on a .NET Developer Machine

To always have the development machine fast and clean, I started a new routine on monday morning: I clean up my machine from unuseful folders and files.
As a .NET developer, I have a lot of bin and obj files in my source directory.
For me is: D:_GITHUB_ and D:_DEVOPS_.
I have two separate folders for GitHub and Azure DevOps.
It's not easy to go through all the subfolders and remove the bin and obj folders manually.
This is why I have created a script to do that:

Get-ChildItem .\ -include bin,obj -Recurse | foreach ($_) { remove-item $_.fullname -Force -Recurse }
Enter fullscreen mode Exit fullscreen mode

Launch this command only in your root source directory!

But this is not the only folder that uses a lot of space in your hard disk.
There is another one and it's the NuGet cache folder.
For me, more or less, it's 10GB.
I don't have a script for this folder, because I don't erase this one every week and I do it manually.
You can easily find the folder with the following path:

Just copy and paste the path in File Explorer.

NuGet Packages folder

As I mentioned in the title, these tips are for a .NET Developer, but I use very often React for the frontend projects at work.
So, I have another script for removing all the node_modules from the root source directory.
I don't use the same script because this script is much slower than the other one.

Get-ChildItem .\ -include node_modules -Recurse | foreach ($_) { remove-item $_.fullname -Force -Recurse }
Enter fullscreen mode Exit fullscreen mode

Have a nice clean up scripting routine!

Top comments (1)

ryannz profile image