/ImeTrackr/obj/Release/Package/ImeTrackr.deploy.cmd

https://github.com/elitwilson/ImeTrackr · Batch · 256 lines · 225 code · 31 blank · 0 comment · 116 complexity · 9ae61cb0dc87056e627d65d28801beb3 MD5 · raw file

  1. @rem ---------------------------------------------------------------------------------
  2. @rem Copyright 2008 Microsoft Corporation. All rights reserved.
  3. @rem This is provided as sample to deploy the package using msdeploy.exe
  4. @rem For information about IIS Web Deploy technology,
  5. @rem please visit http://go.microsoft.com/?linkid=9278654
  6. @rem Note: This batch file assumes the package and setparametsrs.xml are in the same folder with this file
  7. @rem ---------------------------------------------------------------------------------
  8. @if %_echo%!==! echo off
  9. setlocal
  10. @rem ---------------------------------------------------------------------------------
  11. @rem Please Make sure you have Web Deploy install in your machine.
  12. @rem Alternatively, you can explicit set the MsDeployPath to the location it is on your machine
  13. @rem set MSDeployPath="C:\Program Files (x86)\IIS\Microsoft Web Deploy V2\"
  14. @rem ---------------------------------------------------------------------------------
  15. @rem ---------------------------------------------------------------------------------
  16. @rem if user does not set MsDeployPath environment variable, we will try to retrieve it from registry.
  17. @rem ---------------------------------------------------------------------------------
  18. if "%MSDeployPath%" == "" (
  19. for /F "usebackq tokens=1,2,*" %%h in (`reg query "HKLM\SOFTWARE\Microsoft\IIS Extensions\MSDeploy" /s ^| findstr -i "InstallPath"`) do (
  20. if /I "%%h" == "InstallPath" (
  21. if /I "%%i" == "REG_SZ" (
  22. if not "%%j" == "" (
  23. if "%%~dpj" == "%%j" (
  24. set MSDeployPath=%%j
  25. ))))))
  26. if not exist "%MSDeployPath%\msdeploy.exe" (
  27. echo. msdeploy.exe is not found on this machine. Please install Web Deploy before execute the script.
  28. echo. Please visit http://go.microsoft.com/?linkid=9278654
  29. goto :usage
  30. )
  31. set RootPath=%~dp0
  32. if /I "%_DeploySetParametersFile%" == "" (
  33. set _DeploySetParametersFile=%RootPath%ImeTrackr.SetParameters.xml
  34. )
  35. set _ArgTestDeploy=
  36. set _ArgDestinationType=auto
  37. set _ArgComputerName=
  38. set _ArgUserName=
  39. set _ArgPassword=
  40. set _ArgEncryptPassword=
  41. set _ArgIncludeAcls=False
  42. set _ArgAuthType=
  43. set _ArgtempAgent=
  44. set _ArgLocalIIS=
  45. set _ArgLocalIISVersion=
  46. @rem ---------------------------------------------------------------------------------
  47. @rem Simple Parse the arguments
  48. @rem ---------------------------------------------------------------------------------
  49. :NextArgument
  50. set _ArgCurrentOriginal=%1
  51. set _ArgCurrent=%~1
  52. if /I "%_ArgCurrent%" == "" goto :GetStarted
  53. if /I "%_ArgCurrent%" == "/T" set _ArgTestDeploy=true&goto :ArgumentOK
  54. if /I "%_ArgCurrent%" == "/Y" set _ArgTestDeploy=false&goto :ArgumentOK
  55. if /I "%_ArgCurrent%" == "/L" set _ArgLocalIIS=true&goto :ArgumentOK
  56. set _ArgFlag=%_ArgCurrent:~0,3%
  57. set _ArgValue=%_ArgCurrent:~3%
  58. if /I "%_ArgFlag%" == "/M:" set _ArgComputerName=%_ArgValue%&goto :ArgumentOK
  59. if /I "%_ArgFlag%" == "/U:" set _ArgUserName=%_ArgValue%&goto :ArgumentOK
  60. if /I "%_ArgFlag%" == "/P:" set _ArgPassword=%_ArgValue%&goto :ArgumentOK
  61. if /I "%_ArgFlag%" == "/E:" set _ArgEncryptPassword=%_ArgValue%&goto :ArgumentOK
  62. if /I "%_ArgFlag%" == "/I:" set _ArgIncludeAcls=%_ArgValue%&goto :ArgumentOK
  63. if /I "%_ArgFlag%" == "/A:" set _ArgAuthType=%_ArgValue%&goto :ArgumentOK
  64. if /I "%_ArgFlag%" == "/G:" set _ArgtempAgent=%_ArgValue%&goto :ArgumentOK
  65. @rem Any addition flags, pass through to the msdeploy
  66. set _ArgMsDeployAdditionalFlags=%_ArgMsDeployAdditionalFlags% %_ArgCurrentOriginal%
  67. :ArgumentOK
  68. shift
  69. goto :NextArgument
  70. :GetStarted
  71. if /I "%_ArgTestDeploy%" == "" goto :usage
  72. if /I "%_ArgDestinationType%" == "" goto :usage
  73. set _Destination=%_ArgDestinationType%
  74. if not "%_ArgComputerName%" == "" set _Destination=%_Destination%,computerName='%_ArgComputerName%'
  75. if not "%_ArgUserName%" == "" set _Destination=%_Destination%,userName='%_ArgUserName%'
  76. if not "%_ArgPassword%" == "" set _Destination=%_Destination%,password='%_ArgPassword%'
  77. if not "%_ArgAuthType%" == "" set _Destination=%_Destination%,authtype='%_ArgAuthType%'
  78. if not "%_ArgEncryptPassword%" == "" set _Destination=%_Destination%,encryptPassword='%_ArgEncryptPassword%'
  79. if not "%_ArgIncludeAcls%" == "" set _Destination=%_Destination%,includeAcls='%_ArgIncludeAcls%'
  80. if not "%_ArgtempAgent%" == "" set _Destination=%_Destination%,tempAgent='%_ArgtempAgent%'
  81. @rem ---------------------------------------------------------------------------------
  82. @rem add -whatif when -T is specified
  83. @rem ---------------------------------------------------------------------------------
  84. if /I "%_ArgTestDeploy%" NEQ "false" (
  85. set _MsDeployAdditionalFlags=%_MsDeployAdditionalFlags% -whatif
  86. )
  87. @rem ---------------------------------------------------------------------------------
  88. @rem add flags for IISExpress when -L is specified
  89. @rem ---------------------------------------------------------------------------------
  90. if /I "%_ArgLocalIIS%" == "true" (
  91. call :SetIISExpressArguments
  92. )
  93. if /I "%_ArgLocalIIS%" == "true" (
  94. if not exist "%IISExpressPath%%IISExpressManifest%" (
  95. echo. IISExpress is not found on this machine. Please install through Web Platform Installer before execute the script.
  96. echo. or remove /L flag
  97. echo. Please visit http://go.microsoft.com/?linkid=9278654
  98. goto :usage
  99. )
  100. if not exist "%IISExpressUserProfileDirectory%" (
  101. echo. %IISExpressUserProfileDirectory% is not exists
  102. echo. IISExpress is found on the machine. But the user have run IISExpress at least once.
  103. echo. Please visit http://go.microsoft.com/?linkid=9278654 for detail
  104. goto :usage
  105. )
  106. set _MsDeployAdditionalFlags=%_MsDeployAdditionalFlags% -appHostConfigDir:%IISExpressUserProfileDirectory% -WebServerDir:"%IISExpressPath%" -webServerManifest:"%IISExpressManifest%"
  107. )
  108. @rem ---------------------------------------------------------------------------------
  109. @rem pass through the addition msdeploy.exe Flags
  110. @rem ---------------------------------------------------------------------------------
  111. set _MsDeployAdditionalFlags=%_MsDeployAdditionalFlags% %_ArgMsDeployAdditionalFlags%
  112. @rem ---------------------------------------------------------------------------------
  113. @rem check the existence of the package file
  114. @rem ---------------------------------------------------------------------------------
  115. if not exist "%RootPath%ImeTrackr.zip" (
  116. echo "%RootPath%ImeTrackr.zip" does not exist.
  117. echo This batch file relies on this deploy source file^(s^) in the same folder.
  118. goto :usage
  119. )
  120. @rem ---------------------------------------------------------------------------------
  121. @rem Execute msdeploy.exe command line
  122. @rem ---------------------------------------------------------------------------------
  123. call :CheckParameterFile
  124. echo. Start executing msdeploy.exe
  125. echo -------------------------------------------------------
  126. if not exist "%_DeploySetParametersFile%" (
  127. echo. "%MSDeployPath%\msdeploy.exe" -source:package='%RootPath%ImeTrackr.zip' -dest:%_Destination% -verb:sync -disableLink:AppPoolExtension -disableLink:ContentExtension -disableLink:CertificateExtension %_MsDeployAdditionalFlags%
  128. "%MSDeployPath%\msdeploy.exe" -source:package='%RootPath%ImeTrackr.zip' -dest:%_Destination% -verb:sync -disableLink:AppPoolExtension -disableLink:ContentExtension -disableLink:CertificateExtension %_MsDeployAdditionalFlags%
  129. ) else (
  130. echo. "%MSDeployPath%\msdeploy.exe" -source:package='%RootPath%ImeTrackr.zip' -dest:%_Destination% -verb:sync -disableLink:AppPoolExtension -disableLink:ContentExtension -disableLink:CertificateExtension -setParamFile:"%RootPath%ImeTrackr.SetParameters.xml" %_MsDeployAdditionalFlags%
  131. "%MSDeployPath%\msdeploy.exe" -source:package='%RootPath%ImeTrackr.zip' -dest:%_Destination% -verb:sync -disableLink:AppPoolExtension -disableLink:ContentExtension -disableLink:CertificateExtension -setParamFile:"%RootPath%ImeTrackr.SetParameters.xml" %_MsDeployAdditionalFlags%
  132. )
  133. goto :eof
  134. @rem ---------------------------------------------------------------------------------
  135. @rem Find and set IISExpress argument.
  136. @rem ---------------------------------------------------------------------------------
  137. :SetIISExpressArguments
  138. if "%IISExpressPath%" == "" (
  139. for /F "usebackq tokens=1,2,*" %%h in (`reg query "HKLM\SOFTWARE\Microsoft\IISExpress" /s ^| findstr -i "InstallPath"`) do (
  140. if /I "%%h" == "InstallPath" (
  141. if /I "%%i" == "REG_SZ" (
  142. if not "%%j" == "" (
  143. if "%%~dpj" == "%%j" (
  144. set IISExpressPath=%%j
  145. ))))))
  146. if "%IISExpressPath%" == "" (
  147. for /F "usebackq tokens=1,2,*" %%h in (`reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\IISExpress" /s ^| findstr -i "InstallPath"`) do (
  148. if /I "%%h" == "InstallPath" (
  149. if /I "%%i" == "REG_SZ" (
  150. if not "%%j" == "" (
  151. if "%%~dpj" == "%%j" (
  152. set IISExpressPath=%%j
  153. ))))))
  154. if "%PersonalDocumentFolder%" == "" (
  155. for /F "usebackq tokens=2*" %%i in (`reg query "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v Personal`) do (
  156. set PersonalDocumentFolder=%%j
  157. ))
  158. if "%IISExpressManifest%" == "" (
  159. for /F "usebackq tokens=1,2,*" %%h in (`reg query "HKLM\SOFTWARE\Microsoft\IISExpress" /s ^| findstr -i "Manifest"`) do (
  160. if /I "%%h" == "Manifest" (
  161. if /I "%%i" == "REG_SZ" (
  162. if not "%%j" == "" (
  163. set IISExpressManifest=%%j
  164. )))))
  165. if "%IISExpressManifest%" == "" (
  166. for /F "usebackq tokens=1,2,*" %%h in (`reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\IISExpress" /s ^| findstr -i "Manifest"`) do (
  167. if /I "%%h" == "Manifest" (
  168. if /I "%%i" == "REG_SZ" (
  169. if not "%%j" == "" (
  170. set IISExpressManifest=%%j
  171. )))))
  172. set IISExpressUserProfileDirectory="%PersonalDocumentFolder%\IISExpress\config"
  173. goto :eof
  174. @rem ---------------------------------------------------------------------------------
  175. @rem CheckParameterFile -- check if the package's setparamters.xml exists or not
  176. @rem ---------------------------------------------------------------------------------
  177. :CheckParameterFile
  178. echo =========================================================
  179. if exist "%_DeploySetParametersFile%" (
  180. echo SetParameters from:
  181. echo "%_DeploySetParametersFile%"
  182. echo You can change IIS Application Name, Physical path, connectionString
  183. echo or other deploy parameters in the above file.
  184. ) else (
  185. echo SetParamterFiles does not exist in package location.
  186. echo Use package embedded defaultValue to deploy.
  187. )
  188. echo -------------------------------------------------------
  189. goto :eof
  190. @rem ---------------------------------------------------------------------------------
  191. @rem Usage
  192. @rem ---------------------------------------------------------------------------------
  193. :usage
  194. echo =========================================================
  195. if not exist "%RootPath%ImeTrackr.deploy-readme.txt" (
  196. echo Usage:%~nx0 [/T^|/Y] [/M:ComputerName] [/U:userName] [/P:password] [/G:tempAgent] [additional msdeploy flags ...]
  197. echo Required flags:
  198. echo /T Calls msdeploy.exe with the "-whatif" flag, which simulates deployment.
  199. echo /Y Calls msdeploy.exe without the "-whatif" flag, which deploys the package to the current machine or destination server
  200. echo Optional flags:
  201. echo. By Default, this script deploy to the current machine where this script is invoked which will use current user credential without tempAgent.
  202. echo. Only pass these arguments when in advance scenario.
  203. echo /M: Msdeploy destination name of remote computer or proxy-URL. Default is local.
  204. echo /U: Msdeploy destination user name.
  205. echo /P: Msdeploy destination password.
  206. echo /G: Msdeploy destination tempAgent. True or False. Default is false.
  207. echo /A: specifies the type of authentication to be used. The possible values are NTLM and Basic. If the wmsvc provider setting is specified, the default authentication type is Basic
  208. otherwise, the default authentication type is NTLM.
  209. echo /L: Deploy to Local IISExpress User Instance.
  210. echo.[additional msdeploy flags]: note: " is required for passing = through command line.
  211. echo "-skip:objectName=setAcl" "-skip:objectName=dbFullSql"
  212. echo.Alternative environment variable _MsDeployAdditionalFlags is also honored.
  213. echo.
  214. echo. Please make sure MSDeploy is installed in the box http://go.microsoft.com/?linkid=9278654
  215. echo.
  216. echo In addition, you can change IIS Application Name, Physical path,
  217. echo connectionString and other deploy parameters in the following file:
  218. echo "%_DeploySetParametersFile%"
  219. echo.
  220. echo For more information about this batch file, visit http://go.microsoft.com/fwlink/?LinkID=183544
  221. ) else (
  222. start notepad "%RootPath%ImeTrackr.deploy-readme.txt"
  223. )
  224. echo =========================================================
  225. goto :eof