PageRenderTime 63ms CodeModel.GetById 43ms app.highlight 17ms RepoModel.GetById 1ms app.codeStats 0ms

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