From f4ea3cdfa358c3677070680eb965d81a3dda24b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduard=20Tom=C3=A0s?= Date: Fri, 6 Oct 2017 12:31:47 +0200 Subject: [PATCH] build script with no parallel msbuild. For using with VSTS (parallel builds seems to cause that some builds fail randomly) --- cli-windows/vsts/build-bits-no-parallel.ps1 | 56 +++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 cli-windows/vsts/build-bits-no-parallel.ps1 diff --git a/cli-windows/vsts/build-bits-no-parallel.ps1 b/cli-windows/vsts/build-bits-no-parallel.ps1 new file mode 100644 index 000000000..4344bdcc8 --- /dev/null +++ b/cli-windows/vsts/build-bits-no-parallel.ps1 @@ -0,0 +1,56 @@ +Param([string] $rootPath) +$scriptPath = Split-Path $script:MyInvocation.MyCommand.Path + +Write-Host "Current script directory is $scriptPath" -ForegroundColor Yellow + +if ([string]::IsNullOrEmpty($rootPath)) { + $rootPath = "$scriptPath\..\.." +} +Write-Host "Root path used is $rootPath" -ForegroundColor Yellow + + +$projectPaths = + @{Path="$rootPath\src\Web\WebMVC";Prj="WebMVC.csproj"}, + @{Path="$rootPath\src\Web\WebSPA";Prj="WebSPA.csproj"}, + @{Path="$rootPath\src\Services\Identity\Identity.API";Prj="Identity.API.csproj"}, + @{Path="$rootPath\src\Services\Catalog\Catalog.API";Prj="Catalog.API.csproj"}, + @{Path="$rootPath\src\Services\Ordering\Ordering.API";Prj="Ordering.API.csproj"}, + @{Path="$rootPath\src\Services\Basket\Basket.API";Prj="Basket.API.csproj"}, + @{Path="$rootPath\src\Services\Location\Locations.API";Prj="Locations.API.csproj"}, + @{Path="$rootPath\src\Services\Marketing\Marketing.API";Prj="Marketing.API.csproj"}, + @{Path="$rootPath\src\Services\Payment\Payment.API";Prj="Payment.API.csproj"}, + @{Path="$rootPath\src\Web\WebStatus";Prj="WebStatus.csproj"} + +$projectPaths | foreach { + $projectPath = $_.Path + $projectFile = $_.Prj + $outPath = $_.Path + "\obj\Docker\publish" + $projectPathAndFile = "$projectPath\$projectFile" + Write-Host "Deleting old publish files in $outPath" -ForegroundColor Yellow + remove-item -path $outPath -Force -Recurse -ErrorAction SilentlyContinue + Write-Host "Publishing $projectPathAndFile to $outPath" -ForegroundColor Yellow + dotnet restore $projectPathAndFile + dotnet build $projectPathAndFile + dotnet publish $projectPathAndFile -o $outPath + } + +######################################################################################## +# Delete old eShop Docker images +######################################################################################## + +$imagesToDelete = docker images --filter=reference="eshop/*" -q + +If (-Not $imagesToDelete) {Write-Host "Not deleting eShop images as there are no eShop images in the current local Docker repo."} +Else +{ + # Delete all containers + Write-Host "Deleting all containers in local Docker Host" + docker rm $(docker ps -a -q) -f + + # Delete all eshop images + Write-Host "Deleting eShop images in local Docker repo" + Write-Host $imagesToDelete + docker rmi $(docker images --filter=reference="eshop/*" -q) -f +} + +# 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