Invoke VsDevCmd in scripts without changing working directory (dotnet/core-setup...
authorJacek Blaszczynski <biosciencenow@outlook.com>
Tue, 6 Feb 2018 17:25:44 +0000 (18:25 +0100)
committerWes Haggard <weshaggard@users.noreply.github.com>
Tue, 6 Feb 2018 17:25:44 +0000 (09:25 -0800)
* Invoke VsDevCmd in scripts without changing working directory
* Fix help message display in clean.cmd script

Fixes dotnet/core-setup#3429

Commit migrated from https://github.com/dotnet/core-setup/commit/29f970a95ba3e95ee7c6e6f6a7771b2e7ae34bbc

src/installer/clean.cmd
src/installer/corehost/build.cmd
src/installer/run.cmd
src/installer/uwp/build.cmd

index 15beb9f..338f505 100644 (file)
@@ -1,8 +1,20 @@
 @if not defined _echo @echo off
 setlocal EnableDelayedExpansion
 
-echo Stop VBCSCompiler.exe execution.
-for /f "tokens=2 delims=," %%F in ('tasklist /nh /fi "imagename eq VBCSCompiler.exe" /fo csv') do taskkill /f /PID %%~F
+set NO_DASHES_ARG=%1
+if not defined NO_DASHES_ARG goto no_help
+if /I [%NO_DASHES_ARG:-=%] == [?] goto Usage
+if /I [%NO_DASHES_ARG:-=%] == [h] goto Usage
+
+:no_help
+
+:: Check if VBCSCompiler.exe is running
+tasklist /fi "imagename eq VBCSCompiler.exe" |find ":" > nul
+:: Compiler is running if errorlevel == 1
+if errorlevel 1 (
+       echo Stop VBCSCompiler.exe execution.
+       for /f "tokens=2 delims=," %%F in ('tasklist /nh /fi "imagename eq VBCSCompiler.exe" /fo csv') do taskkill /f /PID %%~F
+)
 
 :: Strip all dashes off the argument and use invariant
 :: compare to match as many versions of "all" that we can
index 3ee5b6a..baeb53e 100644 (file)
@@ -51,6 +51,7 @@ if exist %_VSWHERE% (
 if not exist "%_VSCOMNTOOLS%" set _VSCOMNTOOLS=%VS140COMNTOOLS%
 if not exist "%_VSCOMNTOOLS%" goto :MissingVersion
 
+set VSCMD_START_DIR="%~dp0"
 call "%_VSCOMNTOOLS%\VsDevCmd.bat"
 
 :RunVCVars
index eb193fb..0bdce23 100644 (file)
@@ -9,11 +9,12 @@ if exist %_VSWHERE% (
 )
 if not exist "%_VSCOMNTOOLS%" set _VSCOMNTOOLS=%VS140COMNTOOLS%
 if not exist "%_VSCOMNTOOLS%" (
-  echo Error: Visual Studio 2015 or 2017 required.
-  echo        Please see https://github.com/dotnet/corefx/blob/master/Documentation/project-docs/developer-guide.md for build instructions.
-  exit /b 1
+    echo Error: Visual Studio 2015 or 2017 required.
+    echo        Please see https://github.com/dotnet/corefx/blob/master/Documentation/project-docs/developer-guide.md for build instructions.
+    exit /b 1
 )
 
+set VSCMD_START_DIR="%~dp0"
 call "%_VSCOMNTOOLS%\VsDevCmd.bat"
 
 :Run
index 4b2d001..c245d7e 100644 (file)
@@ -42,6 +42,7 @@ if exist %_VSWHERE% (
 if not exist "%_VSCOMNTOOLS%" set _VSCOMNTOOLS=%VS140COMNTOOLS%
 if not exist "%_VSCOMNTOOLS%" goto :MissingVersion
 
+set VSCMD_START_DIR="%~dp0"
 call "%_VSCOMNTOOLS%\VsDevCmd.bat"
 
 :RunVCVars