Advertisement
Guest User

Untitled

a guest
Oct 3rd, 2016
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.83 KB | None | 0 0
  1. cd Server
  2.  
  3. @if "%SCM_TRACE_LEVEL%" NEQ "4" @echo off
  4.  
  5. :: ----------------------
  6. :: KUDU Deployment Script
  7. :: Version: 1.0.8
  8. :: ----------------------
  9.  
  10. :: Prerequisites
  11. :: -------------
  12.  
  13. :: Verify node.js installed
  14. where node 2>nul >nul
  15. IF %ERRORLEVEL% NEQ 0 (
  16.   echo Missing node.js executable, please install node.js, if already installed make sure it can be reached from current environment.
  17.   goto error
  18. )
  19.  
  20. :: Setup
  21. :: -----
  22.  
  23. setlocal enabledelayedexpansion
  24.  
  25. SET ARTIFACTS=%~dp0%..\artifacts
  26.  
  27. IF NOT DEFINED DEPLOYMENT_SOURCE (
  28.   SET DEPLOYMENT_SOURCE=%~dp0%.
  29. )
  30.  
  31. IF NOT DEFINED DEPLOYMENT_TARGET (
  32.   SET DEPLOYMENT_TARGET=%ARTIFACTS%\wwwroot
  33. )
  34.  
  35. IF NOT DEFINED NEXT_MANIFEST_PATH (
  36.   SET NEXT_MANIFEST_PATH=%ARTIFACTS%\manifest
  37.  
  38.   IF NOT DEFINED PREVIOUS_MANIFEST_PATH (
  39.     SET PREVIOUS_MANIFEST_PATH=%ARTIFACTS%\manifest
  40.   )
  41. )
  42.  
  43. IF NOT DEFINED KUDU_SYNC_CMD (
  44.   :: Install kudu sync
  45.   echo Installing Kudu Sync
  46.   call npm install kudusync -g --silent
  47.   IF !ERRORLEVEL! NEQ 0 goto error
  48.  
  49.   :: Locally just running "kuduSync" would also work
  50.   SET KUDU_SYNC_CMD=%appdata%\npm\kuduSync.cmd
  51. )
  52. IF NOT DEFINED DEPLOYMENT_TEMP (
  53.   SET DEPLOYMENT_TEMP=%temp%\___deployTemp%random%
  54.   SET CLEAN_LOCAL_DEPLOYMENT_TEMP=true
  55. )
  56.  
  57. IF DEFINED CLEAN_LOCAL_DEPLOYMENT_TEMP (
  58.   IF EXIST "%DEPLOYMENT_TEMP%" rd /s /q "%DEPLOYMENT_TEMP%"
  59.   mkdir "%DEPLOYMENT_TEMP%"
  60. )
  61.  
  62. IF DEFINED MSBUILD_PATH goto MsbuildPathDefined
  63. SET MSBUILD_PATH=%ProgramFiles(x86)%\MSBuild\14.0\Bin\MSBuild.exe
  64. :MsbuildPathDefined
  65. ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  66. :: Deployment
  67. :: ----------
  68.  
  69. echo Handling ASP.NET Core Web Application deployment.
  70.  
  71. :: 1. Restore nuget packages
  72. call :ExecuteCmd nuget.exe restore -packagesavemode nuspec
  73. IF !ERRORLEVEL! NEQ 0 goto error
  74.  
  75. :: 2. Build and publish
  76. call :ExecuteCmd Tools\dotnet\dotnet.exe publish "Server" --output "%DEPLOYMENT_TEMP%" --configuration Release
  77. IF !ERRORLEVEL! NEQ 0 goto error
  78.  
  79. :: 3. KuduSync
  80. call :ExecuteCmd "%KUDU_SYNC_CMD%" -v 50 -f "%DEPLOYMENT_TEMP%" -t "%DEPLOYMENT_TARGET%" -n "%NEXT_MANIFEST_PATH%" -p "%PREVIOUS_MANIFEST_PATH%" -i ".git;.hg;.deployment;deploy.cmd"
  81. IF !ERRORLEVEL! NEQ 0 goto error
  82.  
  83. ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  84. goto end
  85.  
  86. :: Execute command routine that will echo out when error
  87. :ExecuteCmd
  88. setlocal
  89. set _CMD_=%*
  90. call %_CMD_%
  91. if "%ERRORLEVEL%" NEQ "0" echo Failed exitCode=%ERRORLEVEL%, command=%_CMD_%
  92. exit /b %ERRORLEVEL%
  93.  
  94. :error
  95. endlocal
  96. echo An error has occurred during web site deployment.
  97. call :exitSetErrorLevel
  98. call :exitFromFunction 2>nul
  99.  
  100. :exitSetErrorLevel
  101. exit /b 1
  102.  
  103. :exitFromFunction
  104. ()
  105.  
  106. :end
  107. endlocal
  108. echo Finished successfully.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement