1
1
@ if not defined _echo @ echo off
2
2
setlocal EnableDelayedExpansion
3
3
4
- echo Running clean.cmd
5
4
6
- set bin = false
7
- set packages = false
8
- set tools = false
9
-
10
- if [%1 ]== [] (
11
- set bin = true
12
- set packages = true
13
- set tools = true
14
- set all = false
15
- goto Begin
16
- )
17
-
18
- :Loop
19
- if [%1 ]== [] goto Begin
20
-
21
- if /I [%1 ] == [-?] goto Usage
22
- if /I [%1 ] == [-help] goto Usage
23
-
24
- if /I [%1 ] == [-p] (
25
- set packages = true
26
- set thisArgs = !thisArgs! %1
27
- goto Next
28
- )
29
-
30
- if /I [%1 ] == [-b] (
31
- set bin = true
32
- set thisArgs = !thisArgs! %1
33
- goto Next
34
- )
35
-
36
- if /I [%1 ] == [-t] (
37
- set tools = true
38
- set thisArgs = !thisArgs! %1
39
- goto Next
40
- )
41
-
42
- if /I [%1 ] == [-all] (
43
- set tools = true
44
- set bin = true
45
- set packages = true
46
- set all = true
47
- goto Begin
48
- )
49
-
50
- :Next
51
- shift /1
52
- goto Loop
53
-
54
- :Begin
55
- :: Set __ProjectDir to be the directory of this script
56
- set " __ProjectDir = %~dp0 "
57
- :: remove trailing slash
58
- if %__ProjectDir:~-1 % == \ set " __ProjectDir = %__ProjectDir:~0 ,-1 % "
59
- set " __RootBinDir = %__ProjectDir% \bin"
60
-
61
- :: Check if VBCSCompiler.exe is running and stop it
5
+ :: Check if VBCSCompiler.exe is running
62
6
tasklist /fi " imagename eq VBCSCompiler.exe" | find " :" > nul
7
+ :: Compiler is running if errorlevel == 1
63
8
if errorlevel 1 (
64
9
echo Stop VBCSCompiler.exe execution.
65
10
for /f " tokens=2 delims=," %%F in ('tasklist /nh /fi " imagename eq VBCSCompiler.exe" /fo csv') do taskkill /f /PID %%~F
66
11
)
67
12
68
- if [%bin% ] == [true] (
69
- if exist " %__RootBinDir% " (
70
- echo Deleting bin directory
71
- rd /s /q " %__RootBinDir% "
72
- if NOT [!ERRORLEVEL! ]== [0] (
73
- echo ERROR: An error occurred while deleting the bin directory - error code is !ERRORLEVEL!
74
- exit /b 1
75
- )
76
- )
77
- )
78
-
79
- if [%tools% ] == [true] (
80
- if exist " %__ProjectDir% \Tools" (
81
- echo Deleting tools directory
82
- rd /s /q " %__ProjectDir% \Tools"
83
- if NOT [!ERRORLEVEL! ]== [0] (
84
- echo ERROR: An error occurred while deleting the Tools directory - error code is !ERRORLEVEL!
85
- exit /b 1
86
- )
87
- )
88
- )
89
-
90
- if [%packages% ] == [true] (
91
- if exist " %__ProjectDir% \packages" (
92
- echo Deleting packages directory
93
- rd /s /q " %__ProjectDir% \packages"
94
- if NOT [!ERRORLEVEL! ]== [0] (
95
- echo ERROR: An error occurred while deleting the packages directory - error code is !ERRORLEVEL!
96
- exit /b 1
97
- )
98
- )
99
- )
100
-
101
- if [%all% ] == [true] (
13
+ :: Strip all dashes off the argument and use invariant
14
+ :: compare to match as many versions of "all" that we can
15
+ :: All other argument validation happens inside Run.exe
16
+ set NO_DASHES_ARG = %1
17
+ if not defined NO_DASHES_ARG goto no_args
18
+ if /I [%NO_DASHES_ARG:- =% ] == [all] (
102
19
echo Cleaning entire working directory ...
103
20
call git clean -xdf
104
21
exit /b !ERRORLEVEL!
105
22
)
106
23
107
- echo Clean was successful
108
- exit /b 0
24
+ :no_args
25
+ if [%1 ]== [] set __args = -b
26
+ call %~dp0 run.cmd clean %__args% %*
27
+ exit /b %ERRORLEVEL%
109
28
110
29
:Usage
111
30
echo .
112
31
echo Repository cleaning script.
113
32
echo Options:
114
33
echo -b - Cleans the bin directory
115
34
echo -p - Cleans the packages directory
116
- echo -t - Cleans the tools directory
35
+ echo -c - Deletes the user-local nuget package cache.
117
36
echo -all - Cleans everything and restores repository to pristine state
118
37
echo .
119
- echo If no option is specified then clean.cmd -b -p -t is implied.
38
+ echo If no option is specified then clean.cmd -b is implied.
120
39
exit /b
0 commit comments