Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

436 lines
14 KiB

  1. @echo off
  2. REM
  3. REM Generate ClickOnce Redist.msi from base\ClickOnce Redist.msi
  4. REM copy setup.exe etc from .\base
  5. REM set package code
  6. REM change clickonce registry key value
  7. REM set product code
  8. REM set product version
  9. REM
  10. REM Assumes i386 build env (we don't build MSI for any other archs)
  11. REM Assume run from clickonce\msi
  12. REM Contact: felixybc
  13. REM
  14. echo Building Clickonce Redist.msi
  15. REM (need this switch for the BuildNum stuff below to work)
  16. setlocal ENABLEDELAYEDEXPANSION
  17. set MSIIDTDIR=.\~msiidt
  18. set SOURCE=..
  19. set O_PATH=obj\i386
  20. set TARGET=.\bld
  21. set BASE=.\base
  22. set MSIORINAME="%BASE%\ClickOnce Redist.msi"
  23. set MSINAME=ClickOnce Redist.msi
  24. set VERSIONFILE=..\includes\version.h
  25. REM make tempdirs
  26. if exist %MSIIDTDIR% (
  27. rmdir /q /s %MSIIDTDIR%
  28. if errorlevel 1 call errmsg.cmd "err deleting %MSIIDTDIR% dir"& goto errend
  29. )
  30. mkdir %MSIIDTDIR%
  31. if errorlevel 1 call errmsg.cmd "err creating %MSIIDTDIR% dir"& goto errend
  32. REM replace .\foobar with full path
  33. set MSIIDTDIR=%CD%\!MSIIDTDIR:~2!
  34. REM verify source files
  35. if not exist %SOURCE%\shell\dll\%O_PATH%\adfshell.dll (
  36. call errmsg.cmd "adfshell.dll is missing for clickonceMsiBuild.cmd"
  37. goto errend
  38. )
  39. if not exist %SOURCE%\mime\%O_PATH%\manifest.ocx (
  40. call errmsg.cmd "manifest.ocx is missing for clickonceMsiBuild.cmd"
  41. goto errend
  42. )
  43. if not exist %SOURCE%\tools\mg\%O_PATH%\mg.exe (
  44. call errmsg.cmd "mg.exe is missing for clickonceMsiBuild.cmd"
  45. goto errend
  46. )
  47. if not exist %SOURCE%\tools\lv\%O_PATH%\lv.exe (
  48. call errmsg.cmd "lv.exe is missing for clickonceMsiBuild.cmd"
  49. goto errend
  50. )
  51. if not exist %SOURCE%\ndphost\NDPHost.exe (
  52. call errmsg.cmd "NDPhost.exe is missing for clickonceMsiBuild.cmd"
  53. goto errend
  54. )
  55. if not exist %SOURCE%\tools\pg\%O_PATH%\pg.exe (
  56. call errmsg.cmd "pg.exe is missing for clickonceMsiBuild.cmd"
  57. goto errend
  58. )
  59. if not exist %SOURCE%\service\proxy\%O_PATH%\adfproxy.dll (
  60. call errmsg.cmd "adfproxy.dll is missing for clickonceMsiBuild.cmd"
  61. goto errend
  62. )
  63. if not exist %SOURCE%\service\server\%O_PATH%\adfsvcs.exe (
  64. call errmsg.cmd "adfsvcs.exe is missing for clickonceMsiBuild.cmd"
  65. goto errend
  66. )
  67. if not exist %SOURCE%\dll\%O_PATH%\adfnet.dll (
  68. call errmsg.cmd "adfnet.dll is missing for clickonceMsiBuild.cmd"
  69. goto errend
  70. )
  71. if not exist %MSIORINAME% (
  72. call errmsg.cmd "%MSIORINAME% is missing for clickonceMsiBuild.cmd"
  73. goto errend
  74. )
  75. REM get build num
  76. if NOT EXIST %VERSIONFILE% (echo Can't find version.h.&goto :ErrEnd)
  77. for /f "tokens=3" %%i in ('findstr /c:"#define FUS_VER_MAJORVERSION " %VERSIONFILE%') do (
  78. set /a ProductMajor="%%i"
  79. set BuildNum=%%i
  80. )
  81. for /f "tokens=3" %%i in ('findstr /c:"#define FUS_VER_MINORVERSION " %VERSIONFILE%') do (
  82. set /a ProductMinor="%%i"
  83. set BuildNum=!BuildNum!.%%i
  84. )
  85. for /f "tokens=3" %%i in ('findstr /c:"#define FUS_VER_PRODUCTBUILD " %VERSIONFILE%') do (
  86. set /a ProductBuild="%%i"
  87. set BuildNum=!BuildNum!.%%i
  88. )
  89. for /f "tokens=3" %%i in ('findstr /c:"#define FUS_VER_PRODUCTBUILD_QFE " %VERSIONFILE%') do (
  90. set /a ProductQfe="%%i"
  91. set BuildNum=!BuildNum!.%%i
  92. )
  93. REM pad 0 if needed
  94. if %ProductBuild% LEQ 999 (
  95. set TARGET=!TARGET!0%ProductBuild%
  96. ) else (
  97. set TARGET=!TARGET!%ProductBuild%
  98. )
  99. echo Destination: %TARGET%
  100. echo _
  101. REM replace .\foobar with full path
  102. set MSINAME="%CD%\%TARGET:~2%\!MSINAME!"
  103. if exist "%TARGET%" (
  104. rmdir /q /s "%TARGET%"
  105. if errorlevel 1 call errmsg.cmd "err deleting %TARGET% dir"& goto errend
  106. )
  107. mkdir "%TARGET%"
  108. if errorlevel 1 call errmsg.cmd "err creating %TARGET% dir"& goto errend
  109. mkdir "%TARGET%\program files"
  110. if errorlevel 1 call errmsg.cmd "err creating %TARGET%\program files dir"& goto errend
  111. mkdir "%TARGET%\program files\Microsoft ClickOnce"
  112. if errorlevel 1 call errmsg.cmd "err creating %TARGET%\program files\Microsoft Clickonce dir"& goto errend
  113. mkdir "%TARGET%\system32"
  114. if errorlevel 1 call errmsg.cmd "err creating %TARGET%\system32 dir"& goto errend
  115. REM copy files
  116. copy %SOURCE%\shell\dll\%O_PATH%\adfshell.dll "%TARGET%\program files\Microsoft ClickOnce" > nul
  117. copy %SOURCE%\mime\%O_PATH%\manifest.ocx "%TARGET%\program files\Microsoft ClickOnce" > nul
  118. copy %SOURCE%\tools\mg\%O_PATH%\mg.exe "%TARGET%\program files\Microsoft ClickOnce" > nul
  119. copy %SOURCE%\tools\lv\%O_PATH%\lv.exe "%TARGET%\program files\Microsoft ClickOnce" > nul
  120. copy %SOURCE%\ndphost\NDPHost.exe "%TARGET%\program files\Microsoft ClickOnce" > nul
  121. copy %SOURCE%\tools\pg\%O_PATH%\pg.exe "%TARGET%\program files\Microsoft ClickOnce" > nul
  122. copy %SOURCE%\service\proxy\%O_PATH%\adfproxy.dll "%TARGET%\program files\Microsoft ClickOnce" > nul
  123. copy %SOURCE%\service\server\%O_PATH%\adfsvcs.exe "%TARGET%\program files\Microsoft ClickOnce" > nul
  124. copy %SOURCE%\dll\%O_PATH%\adfnet.dll "%TARGET%\system32" > nul
  125. REM *****************************************************
  126. REM * Update the MSI *
  127. REM *****************************************************
  128. REM if exist %MSINAME% del %MSINAME%
  129. REM copy %MSIORINAME% %MSINAME%
  130. copy "%BASE%\*" "%TARGET%\*" > nul
  131. if errorlevel 1 call errmsg.cmd "err copying %MSIORINAME% to %MSINAME%" & goto errend
  132. REM *****************************************************
  133. REM * Give every package that gets generated, a new *
  134. REM * product and package code. MSI will always think *
  135. REM * its upgrading. *
  136. REM *****************************************************
  137. call :UpdateProductCode %MSINAME% %MSIIDTDIR%
  138. call :UpdatePackageCode %MSINAME% %MSIIDTDIR%
  139. REM call :SetUpgradeCode %MSINAME% %MSIIDTDIR%
  140. call :UpdateClickonceRegistryString %MSINAME% %MSIIDTDIR%
  141. REM *****************************************************
  142. REM * Update the product version property *
  143. REM *****************************************************
  144. call :SetVersion %MSINAME% %MSIIDTDIR%
  145. REM *****************************************************
  146. REM * Update the filetable with file size and ver info *
  147. REM * assumes the source files are in the same directory*
  148. REM *****************************************************
  149. call cscript.exe .\\wifilver.vbs //nologo /U %MSINAME%
  150. if errorlevel 1 (
  151. call errmsg.cmd "wifilver failed"
  152. goto errend
  153. )
  154. call logmsg.cmd "clickonceMsiBuild.cmd COMPLETED OK!"
  155. REM we're done
  156. endlocal
  157. goto end
  158. REM ******************SUBS START HERE********************
  159. REM *****************************************************
  160. REM * Update version sub *
  161. REM * (updates version in the property table *
  162. REM *****************************************************
  163. :SetVersion
  164. REM
  165. REM Update the version in the Property table
  166. REM
  167. REM %1 is the msi file
  168. call logmsg.cmd "Updating the ProductVersion to !BuildNum! in the property table"
  169. call cscript.exe .\\wiexport.vbs //nologo %1 "%MSIIDTDIR%" Property
  170. copy "%MSIIDTDIR%\Property.idt" "%MSIIDTDIR%\Property.idt.old" > nul
  171. del /f "%MSIIDTDIR%\Property.idt"
  172. REM BUGBUG Property productversion should be like this 1.0.713
  173. for /f "usebackq tokens=1,2 delims= " %%a in ("%MSIIDTDIR%\Property.idt.old") do (
  174. if /i "%%a" == "ProductVersion" (
  175. echo %%a !BuildNum!>>"%MSIIDTDIR%\Property.idt"
  176. ) else (
  177. echo %%a %%b>>"%MSIIDTDIR%\Property.idt"
  178. )
  179. )
  180. REM Set the property that says if this is an x86 or a 64-bit package
  181. REM if /i "%CurArch%" == "i386" (
  182. REM echo Install32 ^1>>"%MSIIDTDIR%\Property.idt"
  183. REM )
  184. REM if /i "%CurArch%" == "ia64" (
  185. REM echo Install64 ^1>>"%MSIIDTDIR%\Property.idt"
  186. REM )
  187. call cscript.exe .\\wiimport.vbs //nologo %1 "%MSIIDTDIR%" Property.idt
  188. REM call logmsg.cmd "Finished updating the ProductVersion in the property table"
  189. goto :EOF
  190. REM *****************************************************
  191. REM * Update product code sub *
  192. REM *****************************************************
  193. :UpdateProductCode
  194. REM Update the product code GUID in the property table
  195. REM
  196. REM %1 is the msi file
  197. call logmsg.cmd "Updating the product code GUID in the property table"
  198. call cscript.exe .\\wiexport.vbs //nologo %1 "%MSIIDTDIR%" Property
  199. copy "%MSIIDTDIR%\Property.idt" "%MSIIDTDIR%\Property.idt.old" > nul
  200. del /f "%MSIIDTDIR%\Property.idt"
  201. uuidgen.exe -c -o"%MSIIDTDIR%\productguid"
  202. for /f "usebackq tokens=1" %%a in ("%MSIIDTDIR%\productguid") do (
  203. set NewGuid=%%a
  204. )
  205. call logmsg.cmd "ProductCode GUID = !NewGuid!"
  206. for /f "usebackq tokens=1,2 delims= " %%a in ("%MSIIDTDIR%\Property.idt.old") do (
  207. if /i "%%a" == "ProductCode" (
  208. echo %%a {%NewGuid%}>>"%MSIIDTDIR%\Property.idt"
  209. ) else (
  210. echo %%a %%b>>"%MSIIDTDIR%\Property.idt"
  211. )
  212. )
  213. call cscript.exe .\wiimport.vbs //nologo %1 "%MSIIDTDIR%" Property.idt
  214. call logmsg.cmd "Finished updating the product code GUID in the property table"
  215. goto :EOF
  216. REM *****************************************************
  217. REM * Update clickonce specific registry string sub *
  218. REM *****************************************************
  219. :UpdateClickonceRegistryString
  220. REM Update registry value in the registry table
  221. REM
  222. REM %1 is the msi file
  223. call logmsg.cmd "Updating the registry value in the registry table"
  224. call cscript.exe .\\wiexport.vbs //nologo %1 "%MSIIDTDIR%" Registry
  225. copy "%MSIIDTDIR%\Registry.idt" "%MSIIDTDIR%\Registry.idt.old" > nul
  226. del /f "%MSIIDTDIR%\Registry.idt"
  227. call logmsg.cmd "clickonce upgrade version in registry = !BuildNum!"
  228. for /f "tokens=1 delims=:" %%n in ('findstr /n /c:"Registry64 " "%MSIIDTDIR%\Registry.idt.old"') do (
  229. set ToSkip=%%n
  230. )
  231. for /f "tokens=1 delims=:" %%n in ('findstr /n /c:"Registry66 " "%MSIIDTDIR%\Registry.idt.old"') do (
  232. set ToSkip2=%%n
  233. )
  234. set /a count=1
  235. for /f "usebackq tokens=*" %%n in ("%MSIIDTDIR%\Registry.idt.old") do (
  236. if !count! EQU %ToSkip% (
  237. for /f "tokens=1,2,3,4,5,6* delims= " %%a in ("%%n") do (
  238. REM should fix this entry name in the msi
  239. REM BUGBUG this does not work if a tab is followed by another tab (empty field)
  240. if /i "%%a" == "Registry64" (
  241. if /i "%%d" == "Version" (
  242. echo %%a %%b %%c %%d %BuildNum% %%f>>"%MSIIDTDIR%\Registry.idt"
  243. ) else (
  244. echo %%a %%b %%c %%d %%e %%f>>"%MSIIDTDIR%\Registry.idt"
  245. call errmsg.cmd "err updating registry value - clickonce Update version value name not found"
  246. )
  247. )
  248. )
  249. ) else (
  250. if !count! EQU %ToSkip2% (
  251. for /f "tokens=1,2,3,4,5,6* delims= " %%a in ("%%n") do (
  252. if /i "%%a" == "Registry66" (
  253. if /i "%%d" == "Version" (
  254. echo %%a %%b %%c %%d %BuildNum% %%f>>"%MSIIDTDIR%\Registry.idt"
  255. ) else (
  256. echo %%a %%b %%c %%d %%e %%f>>"%MSIIDTDIR%\Registry.idt"
  257. call errmsg.cmd "err updating registry value - clickonce CurrentService version value name not found"
  258. )
  259. )
  260. )
  261. ) else (
  262. echo %%n>>"%MSIIDTDIR%\Registry.idt"
  263. )
  264. )
  265. set /a count=!count!+1
  266. )
  267. call cscript.exe .\wiimport.vbs //nologo %1 "%MSIIDTDIR%" Registry.idt
  268. call logmsg.cmd "Finished updating the clickonce specfic registry string in the registry table"
  269. goto :EOF
  270. REM *****************************************************
  271. REM * Update package code sub *
  272. REM *****************************************************
  273. :UpdatePackageCode
  274. REM
  275. REM Update the guid for the package code in the _SummaryInformation table
  276. REM %1 is the msi file
  277. call logmsg.cmd "Updating the package code GUID in the _SummaryInformation table"
  278. call cscript.exe .\\wiexport.vbs //nologo %1 "%MSIIDTDIR%" _SummaryInformation
  279. copy "%MSIIDTDIR%\_SummaryInformation.idt" "%MSIIDTDIR%\_SummaryInformation.idt.old" > nul
  280. del /f "%MSIIDTDIR%\_SummaryInformation.idt"
  281. uuidgen.exe -c -o"%MSIIDTDIR%\packageguid"
  282. for /f "usebackq tokens=1" %%a in ("%MSIIDTDIR%\packageguid") do (
  283. set NewGuid=%%a
  284. )
  285. call logmsg.cmd "ProductCode GUID (package code) = !NewGuid!"
  286. for /f "usebackq tokens=1,2 delims= " %%a in ("%MSIIDTDIR%\_SummaryInformation.idt.old") do (
  287. if "%%a" == "9" (
  288. echo %%a {%NewGuid%}>>"%MSIIDTDIR%\_SummaryInformation.idt"
  289. ) else (
  290. echo %%a %%b>>"%MSIIDTDIR%\_SummaryInformation.idt"
  291. )
  292. )
  293. call cscript.exe .\\wiimport.vbs //nologo %1 "%MSIIDTDIR%" _SummaryInformation.idt
  294. goto :EOF
  295. REM *****************************************************
  296. REM * Set upgrade code to ease future upgrades *
  297. REM *****************************************************
  298. :SetUpgradeCode
  299. REM Update the upgrade code GUID in the property table
  300. REM
  301. REM %1 is the msi file
  302. call logmsg.cmd "Setting the upgrade code GUID in the property table"
  303. call cscript.exe .\\wiexport.vbs //nologo %1 "%MSIIDTDIR%" Property
  304. copy "%MSIIDTDIR%\Property.idt" "%MSIIDTDIR%\Property.idt.old" > nul
  305. del /f "%MSIIDTDIR%\Property.idt"
  306. REM set CurUpgradeGUID=17258378-2B69-4900-9754-1CAD4D0FB7CC
  307. call logmsg.cmd "!CurArch! Upgrade Code GUID = !CurUpgradeGUID!"
  308. for /f "usebackq tokens=1,2 delims= " %%a in ("%MSIIDTDIR%\Property.idt.old") do (
  309. if /i "%%a" == "UpgradeCode" (
  310. echo %%a {!CurUpgradeGuid!}>>"%MSIIDTDIR%\Property.idt"
  311. ) else (
  312. echo %%a %%b>>"%MSIIDTDIR%\Property.idt"
  313. )
  314. )
  315. call cscript.exe .\\wiimport.vbs //nologo %1 "%MSIIDTDIR%" Property.idt
  316. call logmsg.cmd "Finished updating the product code GUID in the property table"
  317. REM Update the upgrade code GUID in the Upgrade table
  318. call logmsg.cmd "Updating the upgrade code in the Upgrade table
  319. call cscript.exe .\\wiexport.vbs //nologo %1 "%MSIIDTDIR%" Upgrade
  320. copy "%MSIIDTDIR%\Upgrade.idt" "%MSIIDTDIR%\Upgrade.idt.old" > nul
  321. del /f "%MSIIDTDIR%\Upgrade.idt"
  322. REM
  323. REM Put the header to the file
  324. REM Echo the first three lines to the file
  325. set /a count=1
  326. for /f "usebackq tokens=*" %%a in ("%MSIIDTDIR%\upgrade.idt.old") do (
  327. if !count! LEQ 3 echo %%a>>"%MSIIDTDIR%\Upgrade.idt"
  328. set /a count=!count!+1
  329. )
  330. for /f "usebackq skip=3 tokens=1,2,3,4,5,6* delims= " %%a in ("%MSIIDTDIR%\Upgrade.idt.old") do (
  331. echo {!CurUpgradeGuid!} %%b %%c %%d %%e %%f>>"%MSIIDTDIR%\Upgrade.idt"
  332. )
  333. call cscript.exe .\\wiimport.vbs //nologo %1 "%MSIIDTDIR%" Upgrade.idt
  334. call logmsg.cmd "Finished updating the Upgrade code in the upgrade table"
  335. goto :EOF
  336. :errend
  337. goto :EOF
  338. :end
  339. seterror.exe 0
  340. goto :EOF