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.

147 lines
6.4 KiB

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