From 0ce41652707a43d43f12d0949334b58ef7f39c6a Mon Sep 17 00:00:00 2001 From: Jacek Blaszczynski Date: Tue, 6 Feb 2018 18:25:44 +0100 Subject: [PATCH] Invoke VsDevCmd in scripts without changing working directory (dotnet/core-setup#3450) * 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 | 16 ++++++++++++++-- src/installer/corehost/build.cmd | 1 + src/installer/run.cmd | 7 ++++--- src/installer/uwp/build.cmd | 1 + 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/installer/clean.cmd b/src/installer/clean.cmd index 15beb9f..338f505 100644 --- a/src/installer/clean.cmd +++ b/src/installer/clean.cmd @@ -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 diff --git a/src/installer/corehost/build.cmd b/src/installer/corehost/build.cmd index 3ee5b6a..baeb53e 100644 --- a/src/installer/corehost/build.cmd +++ b/src/installer/corehost/build.cmd @@ -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 diff --git a/src/installer/run.cmd b/src/installer/run.cmd index eb193fb..0bdce23 100644 --- a/src/installer/run.cmd +++ b/src/installer/run.cmd @@ -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 diff --git a/src/installer/uwp/build.cmd b/src/installer/uwp/build.cmd index 4b2d001..c245d7e 100644 --- a/src/installer/uwp/build.cmd +++ b/src/installer/uwp/build.cmd @@ -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 -- 2.7.4