Docker/debug.ps1
[CmdletBinding()] param ( [Parameter(Mandatory = $false)] [string] $AgentName = "PowerPlatform-DevOps", [Parameter(Mandatory = $false)] [bool] $RebuildBase = $false ) $CurrentLocation = Get-Location Set-Location $PSScriptRoot #Remove-Item .\Microsoft.PowerPlatform.DevOps\ -Recurse -Force -ErrorAction SilentlyContinue #Copy-Item -Path (Get-Item '..\*.*' -Exclude ('Docker')).FullName -Destination .\Microsoft.PowerPlatform.DevOps\ -Recurse -Force if (!(Test-Path -Path c:\Dev\Repos)) { New-Item -Path C:\Dev\Repos -ItemType Directory } $imageResult = docker image ls microsoft.powerplatform.devops.base --quiet if (!$imageResult -or $RebuildBase) { Write-Host "Building base image...." docker build -t microsoft.powerplatform.devops.base:latest . -f Dockerfile.devopsbase } docker build -t microsoft.powerplatform.devops.test:latest --no-cache . $ScriptBlock = { function Launcher([string]$Agent) { start-sleep -Seconds 5 #docker exec -it $Agent powershell Invoke-PowerPlatformDevOps docker exec -it $Agent powershell \devmode.ps1 } function Launcher2([string]$Agent) { start-sleep -Seconds 5 docker exec -it $Agent powershell -NoExit -File ".\start.ps1" "true" } } if (docker ps -a -q -f name=$AgentName) { if (docker ps -q -f name=$AgentName) { Start-Process -FilePath PowerShell -ArgumentList "-Command & {$ScriptBlock Launcher2('$AgentName')}" } else{ Start-Process -FilePath PowerShell -ArgumentList "-Command & {$ScriptBlock Launcher2('$AgentName')}" docker start $AgentName } } else { Start-Process -FilePath PowerShell -ArgumentList "-Command & {$ScriptBlock Launcher2('$AgentName')}" docker run -t -d --name $AgentName -v c:\dev\repos:c:\dev\repos microsoft.powerplatform.devops.test:latest } |