-
-
Notifications
You must be signed in to change notification settings - Fork 666
/
build_deployment.bindings.cmd
171 lines (131 loc) · 4.07 KB
/
build_deployment.bindings.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
@ECHO OFF
SETLOCAL EnableDelayedExpansion EnableExtensions
SET VERSION=0.16.7.0
SET CURRENT_DIR=%CD%
SET BUILD_DIR=%CD%\Build
SET LOGFILE=%CD%\build_deployment.bindings.log
SET DEPLOYMENT_DIR=%BUILD_DIR%\Deployment
SET BINARY_DIR=%BUILD_DIR%\Release
SET FILENAME_BINARY=%DEPLOYMENT_DIR%\ZXing.Net.Bindings.%VERSION%.zip
SET ZIP_TOOL=%CD%\3rdparty\zip\7za.exe
SET SOURCE_EXPORT_DIR=%DEPLOYMENT_DIR%\Source
SET SVN_TOOL=%CD%\3rdparty\Subversion\svn.exe
SET GET_PUBLICKEYTOKEN_TOOL=%CD%\3rdparty\GetPublicKeyToken\GetPublicKeyToken.exe
SET HAS_VALIDATION_ERROR=0
echo. > %LOGFILE%
echo.
echo Check for missing files...
echo.
FOR /F %%b IN (build_deployment_files.bindings.txt) DO (
SET f=%%b
SET f=!f:%%BINARY_DIR%%=%BINARY_DIR%!
SET f=!f:%%CURRENT_DIR%%=%CURRENT_DIR%!
IF NOT EXIST !f! (
ECHO The file !f! were not found
SET HAS_VALIDATION_ERROR=1
)
)
echo Check strong name of the assemblies...
echo (script has to be called in a Visual Studio command prompt, sn.exe has to be in search paths)
echo.
SET VALIDATION_WAS_CALLED=0
FOR /F %%b IN (build_deployment_strong_named_files.bindings.txt) DO (
SET f=%%b
SET f=!f:%%BINARY_DIR%%=%BINARY_DIR%!
SET f=!f:%%CURRENT_DIR%%=%CURRENT_DIR%!
REM validation of the strong name
sn -q -vf !f!
if ERRORLEVEL 1 (
ECHO Re-signing the assembly !f!...
sn -q -Ra !f! Key\private.snk
sn -q -vf !f!
if ERRORLEVEL 1 (
echo Validation failed for !f!
SET HAS_VALIDATION_ERROR=1
)
)
REM validation of the correct signing key
for /F "tokens=1 delims=" %%t in ('"%GET_PUBLICKEYTOKEN_TOOL% !f!"') DO (
SET VALIDATION_WAS_CALLED=1
IF NOT "%%t" == "4e88037ac681fe60" (
echo The assembly !f! is not signed with the correct key. required: 4e88037ac681fe60, found: %%t, re-signing...
sn -q -Ra !f! Key\private.snk
for /F "tokens=2 delims=:" %%t in ('"sn -q -T !f!"') DO (
IF NOT "%%t" == "4e88037ac681fe60" (
echo The assembly !f! is not signed with the correct key. required: 4e88037ac681fe60, found: %%t
SET HAS_VALIDATION_ERROR=1
)
)
)
)
)
IF NOT "!VALIDATION_WAS_CALLED!" == "1" (
ECHO.
ECHO The file validation procedure was not executed. Please check the deployment script.
GOTO END
)
IF NOT "!HAS_VALIDATION_ERROR!" == "0" (
ECHO.
ECHO The file validation procedure was not successful.
GOTO END
)
ECHO.
ECHO Build deployment files in directory
ECHO %DEPLOYMENT_DIR%...
ECHO.
REM
REM prepare deployment directory
REM ***************************************************************************************
IF NOT EXIST "%BUILD_DIR%" GOTO BUILD_DIR_NOT_FOUND
IF NOT EXIST "%BINARY_DIR%" GOTO BINARY_DIR_NOT_FOUND
MKDIR "%DEPLOYMENT_DIR%" >NUL: 2>&1
DEL /F "%DEPLOYMENT_DIR%\%FILENAME_BINARY%" >NUL: 2>&1
REM
REM prepare binaries
REM ***************************************************************************************
ECHO Copy binaries
ECHO.
FOR /F "tokens=1,2 delims= " %%b IN (build_deployment_copy_operations.bindings.txt) DO (
SET f=%%b
SET f=!f:%%BINARY_DIR%%=%BINARY_DIR%!
SET f=!f:%%CURRENT_DIR%%=%CURRENT_DIR%!
SET d=%%c
SET d=!d:%%BINARY_DIR%%=%BINARY_DIR%!
SET d=!d:%%CURRENT_DIR%%=%CURRENT_DIR%!
ECHO Copy !f! to !d! >> %LOGFILE% 2>&1
MKDIR "!d!" >> %LOGFILE% 2>&1
COPY "!f!" "!d!" >> %LOGFILE% 2>&1
if ERRORLEVEL 1 GOTO ERROR_OPERATION
)
REM
REM build archives for binaries
REM ***************************************************************************************
CD "%BINARY_DIR%"
echo Build assembly archive...
echo.
"%ZIP_TOOL%" a -tzip -mx9 -r "%FILENAME_BINARY%" Bindings ..\..\THANKS ..\..\COPYING -xr^^!Documentation >> %LOGFILE% 2>&1
if ERRORLEVEL 1 GOTO ERROR_OPERATION
CD "%CURRENT_DIR%"
REM
REM build nuget archive
REM ***************************************************************************************
echo Build nuget packages...
echo.
CALL nuget-pack.bindings.cmd >> %LOGFILE% 2>&1
GOTO END
:BUILD_DIR_NOT_FOUND
ECHO The directory
ECHO %BUILD_DIR%
ECHO doesn't exist.
ECHO.
GOTO END
:BINARY_DIR_NOT_FOUND
ECHO The directory
ECHO %BINARY_DIR%
ECHO doesn't exist.
ECHO.
GOTO END
:ERROR_OPERATION
ECHO An error occurred, please check the logfile %LOGFILE%
:END
ENDLOCAL