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.

153 lines
6.5 KiB

8 years ago
  1. Param([string] $rootPath)
  2. $scriptPath = Split-Path $script:MyInvocation.MyCommand.Path
  3. Write-Host "Current script directory is $scriptPath" -ForegroundColor Yellow
  4. if ([string]::IsNullOrEmpty($rootPath)) {
  5. $rootPath = "$scriptPath\.."
  6. }
  7. Write-Host "Root path used is $rootPath" -ForegroundColor Yellow
  8. # *** WebMVC paths ***
  9. $webMVCPath = $rootPath + "\src\Web\WebMVC"
  10. $webMVCPathToProject = $webMVCPath + "\WebMVC.csproj"
  11. Write-Host "webMVCPathToProject is $webMVCPathToProject" -ForegroundColor Yellow
  12. $webMVCPathToPub = $webMVCPath + "\obj\Docker\publish"
  13. Write-Host "webMVCPathToPub is $webMVCPathToPub" -ForegroundColor Yellow
  14. # *** WebSPA paths ***
  15. $webSPAPath = $rootPath + "\src\Web\WebSPA"
  16. $webSPAPathToProject = $webSPAPath + "\WebSPA.csproj"
  17. Write-Host "webSPAPathToProject is $webSPAPathToProject" -ForegroundColor Yellow
  18. $webSPAPathToPub = $webSPAPath + "\obj\Docker\publish"
  19. Write-Host "webSPAPathToPub is $webSPAPathToPub" -ForegroundColor Yellow
  20. # *** IdentitySvc paths ***
  21. $identitySvcPath = $rootPath + "\src\Services\Identity\Identity.API"
  22. $identitySvcToProject = $identitySvcPath + "\Identity.API.csproj"
  23. Write-Host "identitySvcToProject is $identitySvcToProject" -ForegroundColor Yellow
  24. $identitySvcPathToPub = $identitySvcPath + "\obj\Docker\publish"
  25. Write-Host "identitySvcPathToPub is $identitySvcPathToPub" -ForegroundColor Yellow
  26. # *** Catalog paths ***
  27. $catalogPath = $rootPath + "\src\Services\Catalog\Catalog.API"
  28. $catalogPathToProject = $catalogPath + "\Catalog.API.csproj"
  29. Write-Host "catalogPathToProject is $catalogPathToProject" -ForegroundColor Yellow
  30. $catalogPathToPub = $catalogPath + "\obj\Docker\publish"
  31. Write-Host "catalogPathToPub is $catalogPathToPub" -ForegroundColor Yellow
  32. # *** Ordering paths ***
  33. $orderingPath = $rootPath + "\src\Services\Ordering\Ordering.API"
  34. $orderingPathToProject = $orderingPath + "\Ordering.API.csproj"
  35. Write-Host "orderingPathToProject is $orderingPathToProject" -ForegroundColor Yellow
  36. $orderingPathToPub = $orderingPath + "\obj\Docker\publish"
  37. Write-Host "orderingPathToPub is $orderingPathToPub" -ForegroundColor Yellow
  38. # *** Basket paths ***
  39. $basketPath = $rootPath + "\src\Services\Basket\Basket.API"
  40. $basketPathToProject = $basketPath + "\Basket.API.csproj"
  41. Write-Host "basketPathToProject is $basketPathToProject" -ForegroundColor Yellow
  42. $basketPathToPub = $basketPath + "\obj\Docker\publish"
  43. Write-Host "basketPathToPub is $basketPathToPub" -ForegroundColor Yellow
  44. ########################################################################################
  45. # Delete old eShop dotnet publish bits
  46. ########################################################################################
  47. # Write-Host "Deleting previous dotnet publish bits from all projects" -ForegroundColor Blue
  48. remove-item -path $WebMVCPathToPub -Force -Recurse -ErrorAction SilentlyContinue
  49. remove-item -path $webSPAPathToPub -Force -Recurse -ErrorAction SilentlyContinue
  50. remove-item -path $identitySvcPathToPub -Force -Recurse -ErrorAction SilentlyContinue
  51. remove-item -path $catalogPathToPub -Force -Recurse -ErrorAction SilentlyContinue
  52. remove-item -path $orderingPathToPub -Force -Recurse -ErrorAction SilentlyContinue
  53. remove-item -path $basketPathToPub -Force -Recurse -ErrorAction SilentlyContinue
  54. ########################################################################################
  55. # Building DotNet bits
  56. ########################################################################################
  57. # WebMVC: Build dotnet bits
  58. Write-Host "WebMVC: Restore Dependencies, dotnet build and dotnet publish" -ForegroundColor Blue
  59. dotnet restore $WebMVCPathToProject
  60. dotnet build $WebMVCPathToProject
  61. dotnet publish $WebMVCPathToProject -o $WebMVCPathToPub
  62. # WebSPA: Build dotnet bits
  63. Write-Host "WebSPA: Installing npm dependencies"
  64. #TEMP COMMENT--- Start-Process -WorkingDirectory $webSPAPath -NoNewWindow -Wait npm i
  65. Write-Host "WebSPA: Restore Dependencies, dotnet build and dotnet publish" -ForegroundColor Blue
  66. dotnet restore $webSPAPathToProject
  67. dotnet build $webSPAPathToProject
  68. dotnet publish $webSPAPathToProject -o $webSPAPathToPub
  69. # Identity Service: Build dotnet bits
  70. Write-Host "Identity Service: Restore Dependencies, dotnet build and dotnet publish" -ForegroundColor Blue
  71. dotnet restore $identitySvcToProject
  72. dotnet build $identitySvcToProject
  73. dotnet publish $identitySvcToProject -o $identitySvcPathToPub
  74. # Catalog Service: Build dotnet bits
  75. Write-Host "Catalog Service: Restore Dependencies, dotnet build and dotnet publish" -ForegroundColor Blue
  76. dotnet restore $catalogPathToProject
  77. dotnet build $catalogPathToProject
  78. dotnet publish $catalogPathToProject -o $catalogPathToPub
  79. # Ordering Service: Build dotnet bits
  80. Write-Host "Ordering Service: Restore Dependencies, dotnet build and dotnet publish" -ForegroundColor Blue
  81. dotnet restore $orderingPathToProject
  82. dotnet build $orderingPathToProject
  83. dotnet publish $orderingPathToProject -o $orderingPathToPub
  84. # Basket Service: Build dotnet bits
  85. Write-Host "Basket Service: Restore Dependencies, dotnet build and dotnet publish" -ForegroundColor Blue
  86. dotnet restore $basketPathToProject
  87. dotnet build $basketPathToProject
  88. dotnet publish $basketPathToProject -o $basketPathToPub
  89. ########################################################################################
  90. # Delete old eShop Docker images
  91. ########################################################################################
  92. $imagesToDelete = docker images --filter=reference="eshop/*" -q
  93. If (-Not $imagesToDelete) {Write-Host "Not deleting eShop images as there are no eShop images in the current local Docker repo."}
  94. Else
  95. {
  96. # Delete all containers
  97. Write-Host "Deleting all containers in local Docker Host"
  98. docker rm $(docker ps -a -q) -f
  99. # Delete all eshop images
  100. Write-Host "Deleting eShop images in local Docker repo"
  101. Write-Host $imagesToDelete
  102. docker rmi $(docker images --filter=reference="eshop/*" -q) -f
  103. }
  104. ########################################################################################
  105. # Build new eShop images
  106. ########################################################################################
  107. # WE DON'T NEED DOCKER BUILD AS WE CAN RUN "DOCKER-COMPOSE BUILD" OR "DOCKER-COMPOSE UP" AND IT WILL BUILD ALL THE IMAGES IN THE .YML FOR US
  108. #*** build docker images ***
  109. # docker build -t eshop/web $webPathToPub
  110. # docker build -t eshop/catalog.api $catalogPathToPub
  111. # docker build -t eshop/ordering.api $orderingApiPathToPub
  112. # docker build -t eshop/basket.api $basketPathToPub
  113. # docker build -t eshop/webspa $webSPAPathToPub
  114. # docker build -t eshop/identity $identitySvcPathToPub