-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.bat
129 lines (102 loc) · 4.2 KB
/
build.bat
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
@ECHO OFF
::--------------------------------------------------------------------
:: Usage: "build [/clean | /rebuild | /release] [/log] [/NoPause] [/?]"
::
:: /clean - Cleans the project
:: /rebuild - Cleans and builds the project (default)
:: /release - Rebuilds the project and performs additional operations
::
:: /doc - Generates and packages the documentation (can be long)
:: /log - Creates a detailed log for the build
::
:: /NoPause - Does not pause after completion
:: /? - Gets the usage for this script
::--------------------------------------------------------------------
COLOR 07
:: Reset ERRORLEVEL
VERIFY OTHER 2>nul
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
IF ERRORLEVEL 1 GOTO ERROR_EXT
SET NO_PAUSE=0
SET PROJECT=GeoSik.proj
SET TARGET=Rebuild
SET GENERATE_DOCUMENTATION=False
SET VERBOSITY=minimal
GOTO ARGS
:: -------------------------------------------------------------------
:: Builds the project
:: -------------------------------------------------------------------
:BUILD
PUSHD .nuget
NuGet.exe restore "packages.config" -PackagesDirectory ..\packages
POPD
msbuild.exe %PROJECT% /nologo /t:%TARGET% /m:%NUMBER_OF_PROCESSORS% /p:GenerateDocumentation="%GENERATE_DOCUMENTATION%" /fl /flp:logfile=build.log;verbosity=%VERBOSITY%;encoding=UTF-8 /nr:False
IF ERRORLEVEL 1 (
COLOR 4E
)
GOTO END
:: -------------------------------------------------------------------
:: Parse command line argument values
:: Note: Currently, last one on the command line wins (ex: /rebuild /clean == /clean)
:: -------------------------------------------------------------------
:ARGS
::IF NOT "x%~5"=="x" GOTO ERROR_USAGE
:ARGS_PARSE
IF /I "%~1"=="/clean" SET TARGET=Clean& SHIFT & GOTO ARGS_PARSE
IF /I "%~1"=="/rebuild" SET TARGET=Rebuild& SHIFT & GOTO ARGS_PARSE
IF /I "%~1"=="/release" SET TARGET=Release& SHIFT & GOTO ARGS_PARSE
IF /I "%~1"=="/doc" SET GENERATE_DOCUMENTATION=True& SHIFT & GOTO ARGS_PARSE
IF /I "%~1"=="/log" SET VERBOSITY=diagnostic& SHIFT & GOTO ARGS_PARSE
IF /I "%~1"=="/NoPause" SET NO_PAUSE=1& SHIFT & GOTO ARGS_PARSE
IF /I "%~1"=="/?" GOTO ERROR_USAGE
IF "%~1" EQU "" GOTO ARGS_DONE
ECHO Unknown command-line switch: %~1
GOTO ERROR_USAGE
:ARGS_DONE
GOTO SETENV
:: -------------------------------------------------------------------
:: Set environment variables
:: -------------------------------------------------------------------
:SETENV
CALL :SetMSBuildToolsPathHelper > nul 2>&1
IF ERRORLEVEL 1 GOTO ERROR_MSBUILD
ECHO SET MSBuildToolsPath=%MSBuildToolsPath%
SET PATH=%CD%\misc\;%MSBuildToolsPath%;%PATH%
GOTO BUILD
:SetMSBuildToolsPathHelper
SET MSBuildToolsPath=
FOR /F "tokens=1,2*" %%i in ('REG QUERY HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\14.0 /V MSBuildToolsPath') DO (
IF "%%i"=="MSBuildToolsPath" (
SET "MSBuildToolsPath=%%k"
)
)
IF "%MSBuildToolsPath%"=="" EXIT /B 1
EXIT /B 0
:: -------------------------------------------------------------------
:: Errors
:: -------------------------------------------------------------------
:ERROR_EXT
ECHO Could not activate command extensions
GOTO END
:ERROR_MSBUILD
ECHO Could not find MSBuild 4.0
GOTO END
:ERROR_USAGE
ECHO Usage: "build [/clean | /rebuild | /release] [/doc] [/log] [/NoPause] [/?]"
ECHO.
ECHO /clean - Cleans the project
ECHO /rebuild - Cleans and builds the project (default)
ECHO /release - Rebuilds the project and performs additional operations
ECHO.
ECHO /doc - Generates and packages the documentation (can be long)
ECHO /log - Creates a detailed log for the build
ECHO.
ECHO /NoPause - Does not pause after completion
ECHO /? - Gets the usage for this script
GOTO END
:: -------------------------------------------------------------------
:: End
:: -------------------------------------------------------------------
:END
@IF NOT "%NO_PAUSE%"=="1" PAUSE
ENDLOCAL