4th Street Bar Hive-Bar

Hive-Bar Powered by Hive beta-fdb5b5b

Community post

Clean disk space by removing bin, obj, packages folders generated by Visual Studio

Introduction

I am using PowerShell every day.

I thought it will be nice to share some of my scripts with other people.
That's why I've created PowerShellLibrary

Script

When using Visual Studio and building solution we generate bin, obj folders with output files. In addition, if you are using Nuget there will be packages folder created in the solution root with downloaded dlls.

If you have many projects on your disk which at some point you've build and you are no longer using them actively free disk space is occupied without any reason.

To clean all those folders and free disk space I've written following script
remove-bin-obj-packages-folders-for-given-path.ps1

Usage

At the bottom, there is an example.

You have to invoke Clear-VisualStudioProjectFolder cmdlet and pass start path (folder which will be searched for Visual Studio projects files.

Clear-VisualStudioProjectFolder "C:\repo\"

After you do this you will see a report

FullName                                                               LastWriteTime        Size [MB]
--------                                                               -------------        ---------
C:\repo\ProofOfConcept\ProofOfConcept.Test\obj                         17-Dec-17 4:52:47 PM 0.00
C:\repo\ProofOfConcept\ProofOfConcept\obj                              17-Dec-17 4:52:47 PM 0.00
C:\repo\powershellgallery\mod3\ISESteroids\2.7.1.7\WPF\WPFDesigner\obj 17-Dec-17 4:52:47 PM 0.00
C:\repo\ExtendedPersonalization\ExtendedPersonalization\obj            17-Dec-17 4:42:45 PM 0.01
C:\repo\ExtendedPersonalization\ExtendedPersonalization\bin            17-Dec-17 4:42:45 PM 0.00
Memory to release 0.01 MB
WARNING: If you type 'Y', all folders listed above will be moved removed.
Are you Sure You Want To Proceed:

Type Y and press enter to clean those folders. In case there is nothing to clean, script will finish work without additional prompts.



Posted on Utopian.io - Rewarding Open Source Contributors

13 upvotes $25.39

Replies (5)

Review before signing

Posting as . Signing with . Keychain permission: Posting. Hive Keychain will ask you to approve this action next.


  
Technical details

Operation fingerprint: