forked from dotnet/orleans
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Build.cmd
100 lines (67 loc) · 3.45 KB
/
Build.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
@if not defined _echo @echo off
setlocal enabledelayedexpansion
SET CMDHOME=%~dp0.
if "%BUILD_FLAGS%"=="" SET BUILD_FLAGS=/m /v:m
if not defined BuildConfiguration SET BuildConfiguration=Debug
:: Clear the 'Platform' env variable for this session, as it's a per-project setting within the build, and
:: misleading value (such as 'MCD' in HP PCs) may lead to build breakage (issue: #69).
set Platform=
:: Locate dotnet.exe, we're processing multi-line output of where.exe and only matchin the first tag of the
:: found version number
set /p REQUIRED_DOTNET_VERSION=< "%~dp0DotnetCLIVersion.txt"
echo .Net Core version required: %REQUIRED_DOTNET_VERSION%
for /f "tokens=1 delims=. " %%a in ("%REQUIRED_DOTNET_VERSION%") do set REQUIRED_DOTNET_VERSION_MAJOR=%%a
for /f "tokens=*" %%i in ('where dotnet.exe') do (
set INSTALLED_DOTNET_EXE=%%i
echo Found dotnet.exe at: "!INSTALLED_DOTNET_EXE!"
for /f "tokens=*" %%j in ('"!INSTALLED_DOTNET_EXE!" --version') do set INSTALLED_DOTNET_VERSION=%%j
if [!INSTALLED_DOTNET_VERSION!] neq [] (
for /f "tokens=1 delims=. " %%a in ("!INSTALLED_DOTNET_VERSION!") do set INSTALLED_DOTNET_VERSION_MAJOR=%%a
)
if [!REQUIRED_DOTNET_VERSION_MAJOR!]==[!INSTALLED_DOTNET_VERSION_MAJOR!] (
echo .Net Core major version is matching !INSTALLED_DOTNET_VERSION!, using the installed version.
set _dotnet="!INSTALLED_DOTNET_EXE!"
goto :dotnet-installed
)
)
:install-dotnet
:: Restore the Tools directory
call %~dp0init-tools.cmd
if NOT [%ERRORLEVEL%]==[0] exit /b 1
set _toolRuntime=%~dp0Tools
set _dotnet=%_toolRuntime%\dotnetcli\dotnet.exe
SET PATH=%_toolRuntime%\dotnetcli;%PATH%
:dotnet-installed
SET TOOLS_PACKAGES_PATH=%CMDHOME%\packages
SET SOLUTION=%CMDHOME%\Orleans.sln
:: Set DateTime suffix for debug builds
if "%BuildConfiguration%" == "Debug" for /f %%j in ('powershell -NoProfile -ExecutionPolicy ByPass Get-Date -format "{yyyyMMddHHmm}"') do set DATE_SUFFIX=%%j
if "%BuildConfiguration%" == "Debug" SET AdditionalConfigurationProperties=;VersionDateSuffix=%DATE_SUFFIX%
if "%1" == "Pack" GOTO :Package
@echo ===== Building %SOLUTION% =====
SET STEP=Download build tools
call %_dotnet% restore "%CMDHOME%\Build\Tools.csproj" --packages %TOOLS_PACKAGES_PATH%
@echo Build %BuildConfiguration% ==============================
SET STEP=Restore %BuildConfiguration%
call %_dotnet% restore %BUILD_FLAGS% /bl:%BuildConfiguration%-Restore.binlog /p:Configuration=%BuildConfiguration%%AdditionalConfigurationProperties% "%SOLUTION%"
@if ERRORLEVEL 1 GOTO :ErrorStop
@echo RESTORE ok for %BuildConfiguration% %SOLUTION%
SET STEP=Build %BuildConfiguration%
call %_dotnet% build --no-restore %BUILD_FLAGS% /bl:%BuildConfiguration%-Build.binlog /p:Configuration=%BuildConfiguration%%AdditionalConfigurationProperties% "%SOLUTION%"
@if ERRORLEVEL 1 GOTO :ErrorStop
@echo BUILD ok for %BuildConfiguration% %SOLUTION%
:Package
@echo Package BuildConfiguration ============================
SET STEP=Pack %BuildConfiguration%
call %_dotnet% pack --no-build --no-restore %BUILD_FLAGS% /bl:%BuildConfiguration%-Pack.binlog /p:Configuration=%BuildConfiguration%%AdditionalConfigurationProperties% "%SOLUTION%"
@if ERRORLEVEL 1 GOTO :ErrorStop
@echo PACKAGE ok for %BuildConfiguration% %SOLUTION%
:BuildFinished
@echo ===== Build succeeded for %SOLUTION% =====
@GOTO :EOF
:ErrorStop
set RC=%ERRORLEVEL%
if "%STEP%" == "" set STEP=%BuildConfiguration%
@echo ===== Build FAILED for %SOLUTION% -- %STEP% with error %RC% - CANNOT CONTINUE =====
exit /B %RC%
:EOF