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.

53 lines
2.2 KiB

8 years ago
8 years ago
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. $projectPaths =
  9. @{Path="$rootPath\src\Web\WebMVC";Prj="WebMVC.csproj"},
  10. @{Path="$rootPath\src\Web\WebSPA";Prj="WebSPA.csproj"},
  11. @{Path="$rootPath\src\Services\Identity\Identity.API";Prj="Identity.API.csproj"},
  12. @{Path="$rootPath\src\Services\Catalog\Catalog.API";Prj="Catalog.API.csproj"},
  13. @{Path="$rootPath\src\Services\Ordering\Ordering.API";Prj="Ordering.API.csproj"},
  14. @{Path="$rootPath\src\Services\Basket\Basket.API";Prj="Basket.API.csproj"}
  15. @{Path="$rootPath\src\Web\WebStatus";Prj="WebStatus.csproj"}
  16. $projectPaths | foreach {
  17. $projectPath = $_.Path
  18. $projectFile = $_.Prj
  19. $outPath = $_.Path + "\obj\Docker\publish"
  20. $projectPathAndFile = "$projectPath\$projectFile"
  21. Write-Host "Deleting old publish files in $outPath" -ForegroundColor Yellow
  22. remove-item -path $outPath -Force -Recurse -ErrorAction SilentlyContinue
  23. Write-Host "Publishing $projectPathAndFile to $outPath" -ForegroundColor Yellow
  24. dotnet restore $projectPathAndFile
  25. dotnet build $projectPathAndFile
  26. dotnet publish $projectPathAndFile -o $outPath
  27. }
  28. ########################################################################################
  29. # Delete old eShop Docker images
  30. ########################################################################################
  31. $imagesToDelete = docker images --filter=reference="eshop/*" -q
  32. If (-Not $imagesToDelete) {Write-Host "Not deleting eShop images as there are no eShop images in the current local Docker repo."}
  33. Else
  34. {
  35. # Delete all containers
  36. Write-Host "Deleting all containers in local Docker Host"
  37. docker rm $(docker ps -a -q) -f
  38. # Delete all eshop images
  39. Write-Host "Deleting eShop images in local Docker repo"
  40. Write-Host $imagesToDelete
  41. docker rmi $(docker images --filter=reference="eshop/*" -q) -f
  42. }
  43. # 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