@@ -67,7 +67,7 @@ function New-EnvJson
6767 $envVariables [$envName ] = $envValue
6868 }
6969 }
70-
70+
7171 # Convert to JSON and save
7272 $jsonPath = Join-Path $dockerContextDirectory " env.g.json"
7373
@@ -195,14 +195,14 @@ if ( $VsDebug)
195195 Write-Host " Environment variable 'DevEnvDir' is not defined." - ForegroundColor Red
196196 exit 1
197197 }
198-
198+
199199 $remoteDebuggerHostDir = " $ ( $env: DevEnvDir ) Remote Debugger\x64"
200200 if ( -not (Test-Path $remoteDebuggerHostDir ))
201201 {
202202 Write-Host " Directory '$remoteDebuggerHostDir ' does not exist." - ForegroundColor Red
203203 exit 1
204204 }
205-
205+
206206 $remoteDebuggerContainerDir = " C:\msvsmon"
207207 $volumeMappings += @ (" -v" , " ${remoteDebuggerHostDir} :${remoteDebuggerContainerDir} :ro" )
208208 $MountPoints += $remoteDebuggerContainerDir
@@ -269,26 +269,31 @@ if (-not $BuildImage)
269269 Write-Host " Building the product in the container." - ForegroundColor Green
270270
271271 # Prepare Build.ps1 arguments
272- $buildCommand = " $SourceDirName \Build.ps1"
273272 if ( $VsDebug )
274273 {
275- $BuildArgs = @ (" -VsDebug" ) + $BuildArgs
274+ $BuildArgs = @ (" -VsDebug" ) + $BuildArgs
276275 }
277- $buildArgsString = $BuildArgs -join " "
278- $buildCommand += " $buildArgsString "
279-
276+
280277 if ( $Interactive )
281278 {
282279 $pwshArgs = " -NoExit"
280+ $BuildArgs = @ (" -Interactive" ) + $BuildArgs
281+ $dockerArgs = @ (" -it" )
283282 }
284283 else
285284 {
286285 $pwshArgs = " -NonInteractive"
286+ $dockerArgs = @ ()
287287 }
288-
289- Write-Host " Executing in container: `" .\Build.ps1 $buildArgsString `" ." - ForegroundColor Cyan
290288
291- docker run -- rm -- memory= 12g @volumeMappings - w $SourceDirName $ImageName pwsh $pwshArgs - Command $buildCommand
289+ $buildArgsString = $BuildArgs -join " "
290+ $volumeMappingsAsString = $volumeMappings -join " "
291+ $dockerArgsAsString = $dockerArgs -join " "
292+
293+
294+ Write-Host " Executing: `` docker run --rm --memory=12g $volumeMappingsAsString -w $SourceDirName $dockerArgsAsString $ImageName pwsh $pwshArgs -Command `" & .\Build.ps1 $buildArgsString `"`` ." - ForegroundColor Cyan
295+
296+ docker run -- rm -- memory= 12g @volumeMappings - w $SourceDirName @dockerArgs $ImageName pwsh $pwshArgs - Command " & .\Build.ps1 $buildArgsString "
292297 if ($LASTEXITCODE -ne 0 )
293298 {
294299 Write-Host " Docker run (build) failed with exit code $LASTEXITCODE " - ForegroundColor Red
0 commit comments