forked from dotnet/wcf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.cmd
129 lines (107 loc) · 3.6 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
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
@if "%_echo%" neq "on" echo off
setlocal EnableDelayedExpansion
:: Note: We've disabled node reuse because it causes file locking issues.
:: The issue is that we extend the build with our own targets which
:: means that that rebuilding cannot successfully delete the task
:: assembly.
:ReadArguments
:: Read in the args to determine whether to run the native build, managed build, or both (default)
set OfficialBuildIdArg=
set "__args= %*"
set processedArgs=
set unprocessedBuildArgs=
:Loop
if [%1]==[] goto Tools
if /I [%1]==[native] (
set __buildSpec=native
set processedArgs=!processedArgs! %1
goto Next
)
if /I [%1] == [managed] (
set __buildSpec=managed
set processedArgs=!processedArgs! %1
goto Next
)
if /I [%1] == [/p:OfficialBuildId] (
if /I [%2]==[] (
echo Error: officialbuildid arg should have a value
exit /b 1
)
set processedArgs=!processedArgs! %1=%2
set OfficialBuildIdArg=/p:OfficialBuildId=%2
shift /1
goto Next
)
if [!processedArgs!]==[] (
call set unprocessedBuildArgs=!__args!
) else (
call set unprocessedBuildArgs=%%__args:*!processedArgs!=%%
)
:Next
shift /1
goto Loop
:Tools
:: Setup VS
if not defined VisualStudioVersion (
if defined VS140COMNTOOLS (
call "%VS140COMNTOOLS%\VsDevCmd.bat"
goto :Build
)
echo Error: build.cmd requires Visual Studio 2015.
:: *** start WCF Content ***
echo Please see https://github.com/dotnet/wcf/blob/master/Documentation/developer-guide.md for build instructions.
:: *** end WCF Content ***
exit /b 1
)
:Build
:: Restore the Tools directory
call %~dp0init-tools.cmd
:: Call the builds
if "%__buildSpec%"=="managed" goto :BuildManaged
:BuildNative
:: Run the Native Windows build
echo [%time%] Building Native Libraries...
:: Generate Native versioning assets
set __binDir=%~dp0bin
set __versionLog=%~dp0version.log
msbuild "%~dp0build.proj" /nologo /t:GenerateVersionHeader /p:NativeVersionHeaderFile="%__binDir%\obj\_version.h" /p:GenerateVersionHeader=true %OfficialBuildIdArg% > "%__versionLog%"
IF EXIST "%~dp0src\native\Windows\build-native.cmd" (
call %~dp0src\native\Windows\build-native.cmd %__args% >nativebuild.log
IF ERRORLEVEL 1 (
echo Native component build failed see nativebuild.log for more details.
) else (
echo [%time%] Successfully built Native Libraries.
)
)
:: If we only wanted to build the native components, exit
if "%__buildSpec%"=="native" goto :eof
:BuildManaged
:: 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=
:: Log build command line
set _buildproj=%~dp0build.proj
set _buildlog=%~dp0msbuild.log
set _binclashLoggerDll=%~dp0Tools\net45\Microsoft.DotNet.Build.Tasks.dll
set _binclashlog=%~dp0binclash.log
set _buildprefix=echo
set _buildpostfix=^> "%_buildlog%"
call :build %__args%
:: Build
set _buildprefix=
set _buildpostfix=
echo [%time%] Building Managed Libraries...
call :build %__args%
goto :AfterBuild
:build
%_buildprefix% msbuild "%_buildproj%" /nologo /maxcpucount /v:minimal /clp:Summary /nodeReuse:false /flp:v=normal;LogFile="%_buildlog%";Append "/l:BinClashLogger,%_binclashLoggerDll%;LogFile=%_binclashlog%" !unprocessedBuildArgs! %_buildpostfix% %OfficialBuildIdArg%
set BUILDERRORLEVEL=!ERRORLEVEL!
goto :eof
:AfterBuild
echo.
:: Pull the build summary from the log file
findstr /ir /c:".*Warning(s)" /c:".*Error(s)" /c:"Time Elapsed.*" "%_buildlog%"
echo [%time%] Build Exit Code = %BUILDERRORLEVEL%
exit /b %BUILDERRORLEVEL%