Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit fe967b3

Browse files
committed
New property /e for cleaning a running process
1 parent 50c1110 commit fe967b3

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

clean.cmd

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ if [%1] == [] (
1212
set clean_targets=
1313
set clean_src=
1414
set clean_tools=
15+
set clean_environment=
1516
set clean_all=
1617
set clean_successful=true
1718

@@ -45,9 +46,15 @@ if /I [%1] == [/t] (
4546
goto Next
4647
)
4748

49+
if /I [%1] == [/e] (
50+
set clean_environment=true
51+
goto Next
52+
)
53+
4854
if /I [%1] == [/all] (
4955
set clean_src=
5056
set clean_tools=
57+
set clean_environment=
5158
set clean_targets=Clean;CleanPackages;CleanPackagesCache;
5259
set clean_all=true
5360
goto Begin
@@ -61,9 +68,10 @@ shift /1
6168
goto Loop
6269

6370
:Begin
71+
if /I [%clean_environment%] == [true] (
72+
call :CleanEnvironment
73+
)
6474

65-
echo Running init-tools.cmd
66-
call %~dp0init-tools.cmd
6775

6876
if /I [%clean_src%] == [true] (
6977
echo Cleaning src directory ...
@@ -73,13 +81,17 @@ if /I [%clean_src%] == [true] (
7381
)
7482

7583
if NOT "%clean_targets%" == "" (
84+
echo Running init-tools.cmd
85+
call %~dp0init-tools.cmd
86+
7687
echo Running msbuild clean targets "%clean_targets:~0,-1%" ...
7788
echo. >> %cleanlog% && echo msbuild.exe %~dp0build.proj /t:%clean_targets:~0,-1% /nologo /v:minimal /flp:v=detailed;Append;LogFile=%cleanlog% >> %cleanlog%
7889
call msbuild.exe %~dp0build.proj /t:%clean_targets:~0,-1% /nologo /v:minimal /flp:v=detailed;Append;LogFile=%cleanlog%
7990
call :CheckErrorLevel
8091
)
8192

8293
if /I [%clean_tools%] == [true] (
94+
call :CleanEnvironment
8395
echo Cleaning tools directory ...
8496
echo. >> %cleanlog% && echo rmdir /s /q %~dp0tools >> %cleanlog%
8597
rmdir /s /q %~dp0tools >> %cleanlog%
@@ -88,6 +100,7 @@ if /I [%clean_tools%] == [true] (
88100
)
89101

90102
if /I [%clean_all%] == [true] (
103+
call :CleanEnvironment
91104
echo Cleaning entire working directory ...
92105
echo. >> %cleanlog% && echo git clean -xdf -e clean.log %~dp0 >> %cleanlog%
93106
call git clean -xdf -e clean.log %~dp0 >> %cleanlog%
@@ -114,6 +127,7 @@ echo /p - Deletes the repo-local nuget package directory.
114127
echo /c - Deletes the user-local nuget package cache.
115128
echo /t - Deletes the tools directory.
116129
echo /s - Deletes the untracked files under src directory (git clean src -xdf).
130+
echo /e - Kills and/or stops the processes that are still running, for example VBCSCompiler.exe
117131
echo /all - Combines all of the above.
118132
echo.
119133
echo If no option is specified then clean.cmd /b is implied.
@@ -125,4 +139,11 @@ if NOT [%ERRORLEVEL%]==[0] (
125139
echo Command exited with ERRORLEVEL %ERRORLEVEL% >> %cleanlog%
126140
set clean_successful=false
127141
)
142+
exit /b
143+
144+
:CleanEnvironment
145+
REM If VBCSCompiler.exe is running we need to kill it
146+
echo Stop VBCSCompiler.exe execution.
147+
echo. >> %cleanlog% && echo Stop VBCSCompiler.exe execution. >> %cleanlog%
148+
for /f "tokens=2 delims=," %%F in ('tasklist /nh /fi "imagename eq VBCSCompiler.exe" /fo csv') do taskkill /f /PID %%~F >> %cleanlog%
128149
exit /b

0 commit comments

Comments
 (0)