@@ -12,6 +12,7 @@ if [%1] == [] (
1212set clean_targets =
1313set clean_src =
1414set clean_tools =
15+ set clean_environment =
1516set clean_all =
1617set 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+
4854if /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
6168goto Loop
6269
6370:Begin
71+ if /I [%clean_environment% ] == [true] (
72+ call :CleanEnvironment
73+ )
6474
65- echo Running init-tools.cmd
66- call %~dp0 init-tools.cmd
6775
6876if /I [%clean_src% ] == [true] (
6977 echo Cleaning src directory ...
@@ -73,13 +81,17 @@ if /I [%clean_src%] == [true] (
7381)
7482
7583if NOT " %clean_targets% " == " " (
84+ echo Running init-tools.cmd
85+ call %~dp0 init-tools.cmd
86+
7687 echo Running msbuild clean targets " %clean_targets:~0 ,-1 % " ...
7788 echo . >> %cleanlog% && echo msbuild.exe %~dp0 build.proj /t:%clean_targets:~0 ,-1 % /nologo /v:minimal /flp:v=detailed;Append;LogFile=%cleanlog% >> %cleanlog%
7889 call msbuild.exe %~dp0 build.proj /t:%clean_targets:~0 ,-1 % /nologo /v:minimal /flp:v=detailed;Append;LogFile=%cleanlog%
7990 call :CheckErrorLevel
8091)
8192
8293if /I [%clean_tools% ] == [true] (
94+ call :CleanEnvironment
8395 echo Cleaning tools directory ...
8496 echo . >> %cleanlog% && echo rmdir /s /q %~dp0 tools >> %cleanlog%
8597 rmdir /s /q %~dp0 tools >> %cleanlog%
@@ -88,6 +100,7 @@ if /I [%clean_tools%] == [true] (
88100)
89101
90102if /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.
114127echo /c - Deletes the user-local nuget package cache.
115128echo /t - Deletes the tools directory.
116129echo /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
117131echo /all - Combines all of the above.
118132echo .
119133echo 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%
128149exit /b
0 commit comments