forked from dotnet/wcf
-
Notifications
You must be signed in to change notification settings - Fork 1
/
clean.cmd
106 lines (85 loc) · 2.21 KB
/
clean.cmd
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
@echo off
setlocal
set cleanlog=%~dp0clean.log
echo Running Clean.cmd %* > %cleanlog%
if [%1] == [] (
set clean_targets=Clean
goto Begin
)
set clean_targets=
set clean_src=
set clean_tools=
set clean_all=
:Loop
if [%1] == [] goto Begin
if /I [%1] == [/?] goto Usage
if /I [%1] == [/b] (
set clean_targets=Clean;%clean_targets%
goto Next
)
if /I [%1] == [/p] (
set clean_targets=CleanPackages;%clean_targets%
goto Next
)
if /I [%1] == [/c] (
set clean_targets=CleanPackagesCache;%clean_targets%
goto Next
)
if /I [%1] == [/s] (
set clean_src=true
goto Next
)
if /I [%1] == [/t] (
set clean_tools=true
goto Next
)
if /I [%1] == [/all] (
set clean_src=
set clean_tools=
set clean_targets=Clean;CleanPackages;CleanPackagesCache;
set clean_all=true
goto Begin
)
echo Unrecognized argument '%1'
goto Usage
:Next
shift /1
goto Loop
:Begin
call %~dp0init-tools.cmd
if /I [%clean_src%] == [true] (
echo Cleaning src directory ...
call git clean %~dp0src -xdf >> %cleanlog%
)
if NOT "%clean_targets%" == "" (
echo Running msbuild clean targets "%clean_targets:~0,-1%" ...
echo msbuild.exe %~dp0build.proj /t:%clean_targets:~0,-1% /nologo /v:minimal /flp:v=diag;Append;LogFile=%cleanlog% >> %cleanlog%
call msbuild.exe %~dp0build.proj /t:%clean_targets:~0,-1% /nologo /v:minimal /flp:v=diag;Append;LogFile=%cleanlog%
if NOT [%ERRORLEVEL%]==[0] (
echo ERROR: An error occurred while cleaning, see %cleanlog% for more details.
exit /b
)
)
if /I [%clean_tools%] == [true] (
echo Cleaning tools directory ...
rmdir /s /q %~dp0tools >> %cleanlog%dir
)
if /I [%clean_all%] == [true] (
echo Cleaning entire working directory ...
call git clean %~dp0 -xdf >> %cleanlog%
)
echo Done Cleaning.
exit /b 0
:Usage
echo.
echo Repository cleaning script.
echo.
echo Options:
echo /b - Deletes the binary output directory.
echo /p - Deletes the repo-local nuget package directory.
echo /c - Deleted the user-local nuget package cache.
echo /t - Deletes the tools directory.
echo /s - Deletes the untracked files under src directory (git clean src -xdf).
echo /all - Combines all of the above.
echo.
echo If no option is specified then clean.cmd /b is implied.