-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclean.ps1
67 lines (57 loc) · 1.4 KB
/
clean.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
[cmdletBinding()]
param(
[switch]$quiet
)
Function remove {
param([string]$item)
If (Test-Path $item){
if (-not $quiet.IsPresent) {
Write-Output "Removing $item"
}
Remove-Item $item -Force -Recurse
}
}
Function Invoke-Cleanup {
if (-not $quiet.IsPresent) {
Write-Output "---------------------"
Write-Output "Invoke-Cleanup"
Write-Output "---------------------"
}
# clean package, bin and obj folders
Get-ChildItem .\ -include packages,bin,obj,node_modules -Recurse | Where-Object {$_.FullName -NotMatch "BuildScripts"} | %{
Write-Host "Removing $($_.fullname)";
remove-item $_.fullname -Force -Recurse
}
#Find nunit files
Get-ChildItem -include *.nunit -Recurse |
ForEach-Object{
if (-not $quiet.IsPresent) {
Write-Host $_
}
$results = "$($_.BaseName).xml"
If (Test-Path $results){
if (-not $quiet.IsPresent) {
Write-Host "Removing $results"
}
Remove-Item $results
}
}
#delete dist folder in directories that have package.json
gci -Recurse package.json | %{
$dir = "$($_.DirectoryName)\dist";
If (Test-Path $dir ){
Write-Output "Removing $dir";
rm $dir -force -recurse
}
}
remove "TestResults"
remove "OpenCover"
remove "Publish"
remove "TestBin"
}
# stop extraneous processes
dotnet build-server shutdown
# cleanup all nuget resources
#dotnet nuget locals --clear all
# remove all bin/obj folders
Invoke-Cleanup