Testing/Install-BuildHelper.ps1
function Install-BuildHelper { param ( # Container name to install the Build Helper into [Parameter(Mandatory=$false)] [string] $ContainerName = (Get-ContainerFromLaunchJson), # Whether to force a reinstall of the app [Parameter(Mandatory=$false)] [switch] $Reinstall, # Version of the build helper app to install, use BC15 if not specified [Parameter(Mandatory=$false)] [string] [ValidateSet('Detect','NAV2018','BC13','BC14','BC15')] $BuildHelperVersion = 'Detect' ) if ($BuildHelperVersion -eq 'Detect') { [Version]$PlatformVersion = [Version]::Parse((Get-AppKeyValue -SourcePath (Get-Location) -KeyName 'platform')) switch ($PlatformVersion.Major) { 11 { $BuildHelperVersion = 'NAV2018' } 13 { $BuildHelperVersion = 'BC13' } 14 { $BuildHelperVersion = 'BC14' } 15 { $BuildHelperVersion = 'BC15' } } } $Install = $false if ($Reinstall.IsPresent) { $Install = $true } else { #test for the existence of the build helper service try { switch ($BuildHelperVersion) { 'NAV2018' { $Uri = 'http://{0}:7047/NAV/WS/Codeunit/NavxAutomatedTestManagement' -f (Get-NavContainerIpAddress $ContainerName) } 'BC13' { $Uri = 'http://{0}:7047/NAV/WS/Codeunit/NavxAutomatedTestManagement' -f (Get-NavContainerIpAddress $ContainerName) } 'BC14' { $Uri = 'http://{0}:7047/NAV/WS/Codeunit/NavxAutomatedTestManagement' -f (Get-NavContainerIpAddress $ContainerName) } 'BC15' { $Uri = 'http://{0}:7047/BC/WS/Codeunit/NavxAutomatedTestManagement' -f (Get-NavContainerIpAddress $ContainerName) } } Invoke-WebRequest $Uri -Credential (New-CredentialFromEnvironmentJson) } catch { $Install = $true } } if ($Install) { $DestinationFile = Join-Path (New-TempDirectory) 'NavBuildHelper.app' switch ($BuildHelperVersion) { 'NAV2018' { $SourceURL = 'https://navxdev.blob.core.windows.net/files/NAV-X_NAV-X%20Build%20Helper_1.0.0.0_NAV2018.app' } 'BC13' { $SourceURL = 'https://navxdev.blob.core.windows.net/files/NAV-X_NAV-X%20Build%20Helper_1.0.0.0_BC13.app' } 'BC14' { $SourceURL = 'https://navxdev.blob.core.windows.net/files/NAV-X_NAV-X%20Build%20Helper_1.0.0.0_BC14.app' } 'BC15' { $SourceURL = 'https://navxdev.blob.core.windows.net/files/NAV-X_NAV-X%20Build%20Helper_1.0.0.0.app' } } Download-File -sourceUrl $SourceURL -destinationFile $DestinationFile Publish-NavContainerApp -containerName $ContainerName -appFile $DestinationFile -install -sync } } Export-ModuleMember -Function Install-BuildHelper |