Advertisement
Guest User

Untitled

a guest
Dec 28th, 2016
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1. $webdeploy = "C:\Program Files (x86)\IIS\Microsoft Web Deploy V3\msdeploy.exe"
  2. $location = Get-Location | Select-Object $_.Path
  3. $packOutput = Join-Path $location "bin\Release\netcoreapp1.1\publish"
  4. $app_offline = Join-Path $location "app_offline-template.htm"
  5.  
  6. $iisApp = "..."
  7. $computerName = "..."
  8. $username = "..."
  9. $password = "..."
  10.  
  11. function DeletePublishFolder()
  12. {
  13. if (Test-Path $packOutput)
  14. {
  15. WriteInfo "Removing publish folder..."
  16. Remove-Item -Force -Recurse $packOutput
  17. }
  18. }
  19.  
  20. function RunNpm()
  21. {
  22. npm run build:prod
  23. if ($LASTEXITCODE -ne 0)
  24. {
  25. WriteFailed "Failed with code $LASTEXITCODE. Exiting..."
  26. Exit
  27. }
  28. }
  29.  
  30. function Publish()
  31. {
  32. dotnet publish -c Release
  33. WriteSuccess "Published!"
  34. }
  35.  
  36. function Deploy()
  37. {
  38. & $webdeploy -verb:sync -source:contentPath=$app_offline -dest:contentPath=$iisApp/app_offline.htm,ComputerName=$computerName,UserName=$username,Password=$password,IncludeAcls="False",AuthType="Basic" -retryAttempts:5 -allowUntrusted
  39.  
  40. if ($LASTEXITCODE -ne 0)
  41. {
  42. WriteFailed "Failed with code $LASTEXITCODE. Exiting..."
  43. Exit
  44. }
  45.  
  46. & $webdeploy -verb:sync -source:IisApp=$packOutput -dest:IisApp=$iisApp,ComputerName=$computerName,UserName=$username,Password=$password,IncludeAcls="False",AuthType="Basic" -enableRule:DoNotDeleteRule -disablerule:BackupRule -enableLink:contentLibExtension -retryAttempts:5 -allowUntrusted
  47.  
  48. if ($LASTEXITCODE -ne 0)
  49. {
  50. WriteFailed "Failed with code $LASTEXITCODE. Exiting..."
  51. Exit
  52. }
  53.  
  54. & $webdeploy -verb:delete -dest:contentPath=$iisApp/app_offline.htm,ComputerName=$computerName,UserName=$username,Password=$password,IncludeAcls="False",AuthType="Basic" -retryAttempts:5 -allowUntrusted
  55.  
  56. if ($LASTEXITCODE -ne 0)
  57. {
  58. WriteFailed "Failed with code $LASTEXITCODE. Exiting..."
  59. Exit
  60. }
  61.  
  62. WriteSuccess "Deployment succeeded!"
  63. }
  64.  
  65. function WriteFailed($text)
  66. {
  67. Write-Host $text -ForegroundColor Red
  68. }
  69.  
  70. function WriteInfo($text)
  71. {
  72. Write-Host $text -ForegroundColor Cyan
  73. }
  74.  
  75. function WriteSuccess($text)
  76. {
  77. Write-Host $text -ForegroundColor Green
  78. }
  79.  
  80. # -----------
  81.  
  82. DeletePublishFolder
  83. RunNpm
  84. Publish
  85. Deploy
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement