Modules/businessdev.ALbuild.RuntimePackages/Public/New-BcRuntimePackage.ps1
|
function New-BcRuntimePackage { <# .SYNOPSIS Generates a runtime package for a published app from a Business Central container. .DESCRIPTION Runs Get-NAVAppRuntimePackage inside the container to produce a platform-specific runtime (.runtime.app) for an already-published app, then copies it to the host. Runtime package generation is an NST (server) operation and therefore requires the container. .PARAMETER Name Container name. .PARAMETER AppName The published app's name. .PARAMETER AppPublisher The app publisher (used for the output file name). .PARAMETER AppVersion The app version. .PARAMETER OutputFolder Host folder to copy the runtime package to. .PARAMETER ServerInstance BC server instance. Default 'BC'. .PARAMETER DockerExecutable The Docker executable to use (default 'docker'). .OUTPUTS System.String - the path to the generated runtime .app on the host. #> [CmdletBinding(SupportsShouldProcess)] [OutputType([string])] param( [Parameter(Mandatory)] [Alias('ContainerName')] [string] $Name, [Parameter(Mandatory)] [string] $AppName, [Parameter(Mandatory)] [string] $AppPublisher, [Parameter(Mandatory)] [string] $AppVersion, [Parameter(Mandatory)] [string] $OutputFolder, [string] $ServerInstance = 'BC', [string] $DockerExecutable = 'docker' ) if (-not $PSCmdlet.ShouldProcess($Name, "Create runtime package for $AppName $AppVersion")) { return } if (-not (Test-Path -LiteralPath $OutputFolder)) { New-Item -Path $OutputFolder -ItemType Directory -Force | Out-Null } $fileName = "$($AppPublisher)_$($AppName)_$($AppVersion).runtime.app" $containerOut = "C:\run\$fileName" Invoke-BcContainerCommand -ContainerName $Name -DockerExecutable $DockerExecutable -Variables @{ ServerInstance = $ServerInstance; AppName = $AppName; AppVersion = $AppVersion; OutFile = $containerOut } -ScriptBlock { Get-NAVAppRuntimePackage -ServerInstance $ServerInstance -Name $AppName -Version $AppVersion -Path $OutFile -ErrorAction Stop Write-Output "Generated $OutFile" } | Out-Null $hostPath = Join-Path $OutputFolder $fileName Invoke-BcDocker -DockerExecutable $DockerExecutable -Quiet -Arguments @('cp', "$($Name):$containerOut", $hostPath) | Out-Null Write-ALbuildLog -Level Success "Created runtime package '$hostPath'." return $hostPath } |