AL/Install-NavAppFromVSCode.ps1
<# .Synopsis Installs apps .Description Installs app and test app from the current project. The apps have to be compiled already. When the apps are installed, they are uninstalled before. This is meant to be used in tasks from VS Code .Parameter ContainerName Token to access Azure DevOps. Can be provided in settings.json .Parameter SourcePath Path to the current project .Parameter skipVerification Add this switch to skip app verification for dependency apps .Parameter TenantScope Add this switch to install the dependency apps in the tenant and not global scope .Example Install-NavAppFromVSCode -SkipVerification -TenantScope #> function Install-NavAppFromVSCode { Param ( [Parameter(Mandatory=$false)] [string] $ContainerName = '', [Parameter(Mandatory=$false)] [string] $SourcePath = (Get-Location), [switch] $SkipVerification, [switch] $TenantScope ) Write-Output "Starting installation of app" $ContainerName = Get-NewContainerName -SourcePath $SourcePath -ContainerName $ContainerName $appName = Get-AppKeyValue -SourcePath $SourcePath -KeyName 'Name' $appVersion = Get-AppKeyValue -SourcePath $SourcePath -KeyName 'Version' $appPublisher = Get-AppKeyValue -SourcePath $SourcePath -KeyName 'Publisher' $appFile = Join-Path $SourcePath ($appPublisher + "_" + $appName + "_" + $appVersion + ".app") if (!(Test-Path $appFile -PathType Leaf)) { throw "App file not found" } Write-Output "Testing, if app is installed" if ($null -ne (Get-BcContainerAppInfo -containerName $ContainerName | Where-Object Name -like ("*{0}*" -f $appName))) { Write-Output "App is installed - removing app" UnPublish-BcContainerApp -containerName $ContainerName -appName $appName -unInstall } else { Write-Output "App is not installed" } Write-Output "Installing app" if (!$SkipVerification.IsPresent) { if ($TenantScope.IsPresent) { Publish-BcContainerApp -containerName $ContainerName -appFile $appFile -install -sync -tenant "default" -scope Tenant } else { Publish-BcContainerApp -containerName $ContainerName -appFile $appFile -install -sync } } else { if ($TenantScope.IsPresent) { Publish-BcContainerApp -containerName $ContainerName -appFile $appFile -sync -skipVerification -install -tenant "default" -scope Tenant } else { Publish-BcContainerApp -containerName $ContainerName -appFile $appFile -sync -skipVerification -install } } Write-Output "App is installed" } Export-ModuleMember Install-NavAppFromVSCode |