-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.cmd
112 lines (93 loc) · 4.5 KB
/
setup.cmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
:PROCESS_CMD
SET "utility_folder=%~dp0"
REM Load dependent tools...
CALL "%utility_folder%..\win-utils\setup.cmd" cecho vswhere
SET help_val=false
:LOOP
SET current_arg=%1
IF [%current_arg%] EQU [-h] (
SET help_val=true
)
IF [%current_arg%] EQU [--help] (
SET help_val=true
)
SHIFT
IF NOT "%~1"=="" GOTO :LOOP
IF [%help_val%] EQU [true] (
CALL :SHOW_HELP
) ELSE (
CALL :MAIN
IF !ERRORLEVEL! NEQ 0 (
EXIT /B !ERRORLEVEL!
)
)
REM All changes to variables within this script, will have local scope. Only
REM variables specified in the following block can propagates to the outside
REM world (For example, a calling script of this script).
ENDLOCAL & (
SET "TOOLSET_MSBUILD_PATH=%msbuild_folder%"
SET "PATH=%PATH%"
)
EXIT /B 0
:MAIN
FOR /f "usebackq tokens=*" %%i IN (`vswhere -latest -requires Microsoft.Component.MSBuild -property installationPath`) DO (
SET installation_base_path=%%i
)
SET "msbuild_folder=%installation_base_path%\MSBuild\Current\Bin"
IF EXIST "%msbuild_folder%" (
IF "!PATH:%msbuild_folder%=!" EQU "%PATH%" (
SET "PATH=%msbuild_folder%;%PATH%"
CALL :SHOW_INFO "Utility added to system path."
)
) ELSE (
CALL :SHOW_ERROR "Unable to find the 'MSBuild' folder."
CALL :SHOW_DETAIL "%msbuild_folder%"
EXIT /B -1
)
EXIT /B 0
:SHOW_INFO
cecho {olive}[TOOLSET - MSBUILD]{default} INFO: %~1{\n}
EXIT /B 0
:SHOW_DETAIL
cecho {white}[TOOLSET - MSBUILD]{default} DETAIL: %~1{\n}
EXIT /B 0
:SHOW_ERROR
cecho {olive}[TOOLSET - MSBUILD]{red} ERROR: %~1 {default} {\n}
EXIT /B 0
:SHOW_HELP
SET "script_name=%~n0%~x0"
ECHO #######################################################################
ECHO # #
ECHO # T O O L S E T U P #
ECHO # #
ECHO # Microsoft Build Engine, better known as 'MSBuild'. #
ECHO # #
ECHO # After running the %SCRIPT_NAME% we can use the Microsoft #
ECHO # MSBuild from the command line. The Microsoft build tools #
ECHO # must be installed beforehand. #
ECHO # #
ECHO # TOOL : MSBuild #
ECHO # VERSION: 1.0.0 #
ECHO # #
ECHO # USAGE: #
ECHO # %SCRIPT_NAME% [-h^|--help] #
ECHO # #
ECHO # EXAMPLES: #
ECHO # %script_name% --help #
ECHO # #
ECHO # ARGUMENTS: #
ECHO # -h^|--help Print this help and exit. #
ECHO # #
ECHO # EXPORTED ENVIRONMENT VARIABLES: #
ECHO # TOOLSET_MSBUILD_PATH The path where the msbuild is located. #
ECHO # #
ECHO # PATH This tool will export all local changes that it made to #
ECHO # the path's environment variable. #
ECHO # #
ECHO # The environment variables will be exported only if this tools #
ECHO # executes without any error. #
ECHO # #
ECHO #######################################################################
EXIT /B 0