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.

159 lines
6.9 KiB

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