Modules/businessdev.ALbuild.OnPrem/Public/Publish-BcOnPremApp.ps1
|
function Publish-BcOnPremApp { <# .SYNOPSIS Publishes an AL app to an on-premises Business Central server instance (licensed). .DESCRIPTION Publishes the .app to the given server instance using the Business Central management cmdlets, optionally synchronising and installing it. Run on a host where the BC management module is available (the BC server or a deployment agent). Requires a valid ALbuild license. .PARAMETER ServerInstance The BC server instance name. .PARAMETER AppFile Path to the .app file. .PARAMETER SkipVerification Publish without signature verification. .PARAMETER Sync Synchronise after publishing. .PARAMETER Install Install after synchronising. .PARAMETER SyncMode Add (default), Clean, Development or ForceSync. .PARAMETER Scope Global (default) or Tenant. .PARAMETER Tenant Tenant. Default 'default'. #> [CmdletBinding(SupportsShouldProcess)] param( [Parameter(Mandatory)] [string] $ServerInstance, [Parameter(Mandatory)] [string] $AppFile, [switch] $SkipVerification, [switch] $Sync, [switch] $Install, [ValidateSet('Add', 'Clean', 'Development', 'ForceSync')] [string] $SyncMode = 'Add', [ValidateSet('Global', 'Tenant')] [string] $Scope = 'Global', [string] $Tenant = 'default' ) Assert-ALbuildLicensed -Feature 'OnPrem' if (-not (Test-Path -LiteralPath $AppFile)) { throw "App file not found: '$AppFile'." } if (-not $PSCmdlet.ShouldProcess($ServerInstance, "Publish $(Split-Path $AppFile -Leaf)")) { return } Publish-NAVApp -ServerInstance $ServerInstance -Path $AppFile -Scope $Scope -SkipVerification:$SkipVerification -ErrorAction Stop $info = Get-NAVAppInfo -Path $AppFile if ($Sync) { Sync-NAVApp -ServerInstance $ServerInstance -Name $info.Name -Version $info.Version -Mode $SyncMode -Tenant $Tenant -Force -ErrorAction Stop } if ($Install) { Install-NAVApp -ServerInstance $ServerInstance -Name $info.Name -Version $info.Version -Tenant $Tenant -ErrorAction Stop } Write-ALbuildLog -Level Success "Published $($info.Name) $($info.Version) to '$ServerInstance'." } |