Last active
February 12, 2018 07:49
-
-
Save alantsai/f6cb333a7583635b14b271659d3a41fd to your computer and use it in GitHub Desktop.
[Remove packages, bin and obj folder 刪除 packages,bin和obj資料夾] 用來快速清理solution裡面非必要檔案減少空間 #powershell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 看看那些會刪掉 | |
dir -Directory -Recurse -Include bin,obj | %{$_.FullName} | |
# 實際刪掉 | |
dir -Directory -Recurse -Include bin,obj | Remove-Item -Force -Recurse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 看看那些會刪掉 | |
dir -Directory -Recurse -Include packages | %{$_.FullName} | |
# 實際刪掉 | |
dir -Directory -Recurse -Include packages | Remove-Item -Force -Recurse | |
# 如果有些檔案的資料夾名稱也會包含packages,但是不應該刪掉 | |
# 例如要保留資料夾名稱有 \Developer\Packages和 App_Data\Packages | |
# 那麼做法如下 | |
# 使用where不是exclude是因為exclude只包含檔名,不包含路徑 | |
dir -Directory -Recurse -Include packages | Where {$_.FullName -notlike "**\Developer\Packages" -and $_.FullName -notlike "*\App_Data\packages"} | %{$_.FullName} | |
# 實際刪掉 | |
dir -Directory -Recurse -Include packages | Where {$_.FullName -notlike "**\Developer\Packages" -and $_.FullName -notlike "*\App_Data\packages"} | Remove-Item -Force -Recurse |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment