Skip to content

Commit 13a0886

Browse files
committed
install script now checks if existing VS environment is already setup.
1 parent 5615b83 commit 13a0886

File tree

1 file changed

+35
-3
lines changed

1 file changed

+35
-3
lines changed

install_script.bat

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ REM Defined cript variables
44
set YASMDL=http://www.tortall.net/projects/yasm/releases
55
set YASMVERSION=1.3.0
66

7+
REM Store current directory and ensure working directory is the location of current .bat
8+
SET CALLDIR=%CD%
9+
cd %~dp0
10+
11+
REM Initialise error check value
12+
SET ERROR=0
13+
714
REM Check what architecture we are installing on
815
if "%PROCESSOR_ARCHITECTURE%"=="AMD64" (
916
echo Detected 64 bit system...
@@ -21,6 +28,25 @@ if "%PROCESSOR_ARCHITECTURE%"=="AMD64" (
2128
goto Terminate
2229
)
2330

31+
REM Check if already running in an environment with VS setup
32+
if defined VCINSTALLDIR (
33+
if defined VisualStudioVersion (
34+
echo Existing Visual Studio environment detected...
35+
if "%VisualStudioVersion%"=="15.0" (
36+
set MSVC_VER=15
37+
goto MSVCVarsDone
38+
) else if "%VisualStudioVersion%"=="14.0" (
39+
set MSVC_VER=14
40+
goto MSVCVarsDone
41+
) else if "%VisualStudioVersion%"=="12.0" (
42+
set MSVC_VER=12
43+
goto MSVCVarsDone
44+
) else (
45+
echo Unknown Visual Studio environment detected '%VisualStudioVersion%', Creating a new one...
46+
)
47+
)
48+
)
49+
2450
REM First check for a environment variable to help locate the VS installation
2551
if defined VS140COMNTOOLS (
2652
if exist "%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat" (
@@ -91,7 +117,6 @@ if exist "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxil
91117
)
92118

93119
:MSVCVarsDone
94-
95120
REM Get the location of the current msbuild
96121
powershell.exe -Command ((Get-Command msbuild.exe).Path ^| Split-Path -parent) > msbuild.txt
97122
set /p MSBUILDDIR=<msbuild.txt
@@ -152,10 +177,17 @@ if not exist "%VCINSTALLDIR%\yasm.exe" (
152177
goto Terminate
153178
)
154179
echo Finished Successfully
180+
goto Exit
155181

156182
:Terminate
157-
pause
158-
exit /b
183+
SET ERROR=1
184+
185+
:Exit
186+
cd %CALLDIR%
187+
IF "%APPVEYOR%"=="" (
188+
pause
189+
)
190+
exit /b %ERROR%
159191

160192
:DownloadYasm
161193
if "%SYSARCH%"=="x32" (

0 commit comments

Comments
 (0)