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.

52 lines
2.1 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. $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. $projectPaths | foreach {
  16. $projectPath = $_.Path
  17. $projectFile = $_.Prj
  18. $outPath = $_.Path + "\obj\Docker\publish"
  19. $projectPathAndFile = "$projectPath\$projectFile"
  20. Write-Host "Deleting $outPath" -ForegroundColor Yellow
  21. remove-item -path $outPath -Force -Recurse -ErrorAction SilentlyContinue
  22. Write-Host "Publishing $projectPathAndFile to $outPath" -ForegroundColor Yellow
  23. dotnet restore $projectPathAndFile
  24. dotnet build $projectPathAndFile
  25. dotnet publish $projectPathAndFile -o $outPath
  26. }
  27. ########################################################################################
  28. # Delete old eShop Docker images
  29. ########################################################################################
  30. $imagesToDelete = docker images --filter=reference="eshop/*" -q
  31. If (-Not $imagesToDelete) {Write-Host "Not deleting eShop images as there are no eShop images in the current local Docker repo."}
  32. Else
  33. {
  34. # Delete all containers
  35. Write-Host "Deleting all containers in local Docker Host"
  36. docker rm $(docker ps -a -q) -f
  37. # Delete all eshop images
  38. Write-Host "Deleting eShop images in local Docker repo"
  39. Write-Host $imagesToDelete
  40. docker rmi $(docker images --filter=reference="eshop/*" -q) -f
  41. }
  42. # 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