File tree Expand file tree Collapse file tree 3 files changed +24
-18
lines changed
src/PostSharp.Engineering.BuildTools/Resources Expand file tree Collapse file tree 3 files changed +24
-18
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ $EngPath = 'eng'
1515$ProductName = ' PostSharpEngineering'
1616# ###
1717
18- if ( $StartVsmon )
18+ if ($StartVsmon )
1919{
2020 $vsmonport = 4024
2121 Write-Host " Starting Visual Studio Remote Debugger, listening at port $vsmonport ." - ForegroundColor Cyan
@@ -25,22 +25,23 @@ if ( $StartVsmon )
2525}
2626
2727# Change the prompt and window title in Docker.
28- if ( $env: RUNNING_IN_DOCKER )
28+ if ($env: RUNNING_IN_DOCKER )
2929{
30- function global :prompt {
30+ function global :prompt
31+ {
3132 $host.UI.RawUI.WindowTitle = " [docker] " + (Get-Location ).Path
32- " [docker] $ ( Get-Location ) > "
33+ " [docker] $ ( Get-Location ) > "
3334 }
3435}
3536
3637
37- if ( -not $Interactive -or $BuildArgs )
38+ if (-not $Interactive -or $BuildArgs )
3839{
3940 # Change the working directory so we can use a global.json that is specific to eng.
4041 $previousLocation = Get-Location
41-
42+
4243 Set-Location $PSScriptRoot \$EngPath \src
43-
44+
4445 try
4546 {
4647
Original file line number Diff line number Diff line change @@ -254,6 +254,12 @@ Write-Host "Volume mappings: " @VolumeMappings -ForegroundColor Gray
254254Write-Host " Mount points: " $mountPointsAsString - ForegroundColor Gray
255255Write-Host " Git directories: " $gitDirectoriesAsString - ForegroundColor Gray
256256
257+ # Kill all containers
258+ docker ps - q -- filter " ancestor=$ImageName " | ForEach-Object {
259+ Write-Host " Killing container $_ "
260+ docker kill $_
261+ }
262+
257263# Building the image.
258264if (-not $NoBuildImage )
259265{
@@ -287,23 +293,23 @@ if (-not $BuildImage)
287293 if ($Interactive )
288294 {
289295 $pwshArgs = " -NoExit"
290- $BuildArgs = @ (" -Interactive" ) + $BuildArgs
291- $dockerArgs = @ (" -it" )
296+ $BuildArgs = @ (" -Interactive" ) + $BuildArgs
297+ $dockerArgs = @ (" -it" )
292298 }
293299 else
294300 {
295301 $pwshArgs = " -NonInteractive"
296- $dockerArgs = @ ()
302+ $dockerArgs = @ ()
297303 }
298304
299305 $buildArgsString = $BuildArgs -join " "
300- $VolumeMappingsAsString = $VolumeMappings -join " "
301- $dockerArgsAsString = $dockerArgs -join " "
306+ $VolumeMappingsAsString = $VolumeMappings -join " "
307+ $dockerArgsAsString = $dockerArgs -join " "
302308
303309
304- Write-Host " Executing: `` docker run --rm --memory=12g $VolumeMappingsAsString -w $SourceDirName $dockerArgsAsString $ImageName pwsh $pwshArgs -Command `" & .\Build.ps1 $buildArgsString `; exit `$ LASTEXITCODE`"`` ." - ForegroundColor Cyan
310+ Write-Host " Executing: `` docker run --rm --memory= 12g $VolumeMappingsAsString -w $SourceDirName $dockerArgsAsString $ImageName pwsh $pwshArgs -Command `" & .\Build.ps1 $buildArgsString `; exit `$ LASTEXITCODE`"`` ." - ForegroundColor Cyan
305311
306- docker run -- rm -- memory= 12g @VolumeMappings - w $SourceDirName @dockerArgs $ImageName pwsh $pwshArgs - Command " & .\Build.ps1 $buildArgsString `; exit `$ LASTEXITCODE;"
312+ docker run -- rm -- memory= 12g @VolumeMappings - w $SourceDirName @dockerArgs $ImageName pwsh $pwshArgs - Command " & .\Build.ps1 $buildArgsString `; exit `$ LASTEXITCODE; "
307313 if ($LASTEXITCODE -ne 0 )
308314 {
309315 Write-Host " Docker run (build) failed with exit code $LASTEXITCODE " - ForegroundColor Red
Original file line number Diff line number Diff line change 1313 [string ]$BuildAgentPath = ' C:\BuildAgent' ,
1414 [switch ]$LoadEnvFromKeyVault , # Forces loading environment variables form the key vault.
1515 [switch ]$StartVsmon , # Enable the remote debugger.
16- [switch ]$KillAll , # Kill all containers before building the image.
1716 [Parameter (ValueFromRemainingArguments )]
1817 [string []]$BuildArgs # Arguments passed to `Build.ps1` within the container.
1918)
@@ -256,9 +255,9 @@ Write-Host "Mount points: " $mountPointsAsString -ForegroundColor Gray
256255Write-Host " Git directories: " $gitDirectoriesAsString - ForegroundColor Gray
257256
258257# Kill all containers
259- docker ps - q | ForEach-Object {
260- Write-Host " Killing container
261- docker rm -f $_
258+ docker ps - q -- filter " ancestor= $ImageName " | ForEach-Object {
259+ Write-Host " Killing container $_ "
260+ docker kill $_
262261}
263262
264263# Building the image.
You can’t perform that action at this time.
0 commit comments