Skip to content

Commit 4901b15

Browse files
Adding PowerShell script to clean the solution folder, fixes #2810
1 parent 408534c commit 4901b15

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

CleanSolution.ps1

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<#
2+
.Synopsis
3+
Cleans the solution: removes all bin and obj folders under src, deletes Dependencies, cache.dat and all mappings.bin files from App_Data.
4+
Just run the script where it is, don't move or run elsewhere.
5+
6+
.EXAMPLE
7+
PS> .\CleanSolution.ps1
8+
9+
#>
10+
11+
# Deleting bin and obj folders.
12+
$currentPath = (Get-Item -Path ".\").FullName
13+
# Add relative file paths here what you want to keep.
14+
$whiteList = @("\src\Orchard.Azure\Orchard.Azure.CloudService\Orchard.Azure.WebContent\Bin\Startup\SetIdleTimeout.cmd")
15+
# Also add the bin/obj folder's path of the paths in the whiteList here. This is needed for performance reasons, the script will run faster this way.
16+
$whiteListFolders = @("\src\Orchard.Azure\Orchard.Azure.CloudService\Orchard.Azure.WebContent\Bin")
17+
18+
Get-ChildItem -Path ($currentPath + "\src\") -Recurse |
19+
Where-Object { $PSItem.PSIsContainer -and ( $PSItem.Name -eq "bin" -or $PSItem.Name -eq "obj") } |
20+
ForEach-Object {
21+
if($whiteListFolders.Contains($PSItem.FullName.Substring($currentPath.Length)))
22+
{
23+
Get-ChildItem -Path $PSItem.FullName -Recurse -File |
24+
ForEach-Object {
25+
if(!$whiteList.Contains($PSItem.FullName.Substring($currentPath.Length)))
26+
{
27+
Remove-Item $PSItem.FullName -Force
28+
}
29+
}
30+
}
31+
else
32+
{
33+
Remove-Item $PSItem.FullName -Recurse -Force
34+
}
35+
}
36+
37+
# Deleting Dependencies and cache.dat from App_Data.
38+
Remove-Item -Path ($currentPath + "\src\Orchard.Web\App_Data\Dependencies\") -Recurse -Force
39+
Remove-Item -Path ($currentPath + "\src\Orchard.Web\App_Data\cache.dat") -Force
40+
41+
# Deleting all mappings.bin files from App_Data.
42+
Get-ChildItem -Path ($currentPath + "\src\Orchard.Web\App_Data\Sites") -Recurse -Include "mappings.bin" |
43+
Remove-Item -Force

0 commit comments

Comments
 (0)