AppFilesHandling/Install-AppsLocally.ps1
<#
.SYNOPSIS Build and install all apps from selected folder .DESCRIPTION Compile and install all apps in a selected folder, if any app matches already installed app, upgrade procedure will be started .EXAMPLE Install-AppsLocally -ContainerName bccontainer -AppsDirectory ~/MyProject/Apps -ArtifactsDirectory ~/MyProject/Artifacts -Credential (Get-Credential) .NOTES The command uses commands from BcContainerHelper to export and compile the objects. Please note that Apps and Artifacts directory must be shared with container #> function Install-AppsLocally { Param( [Parameter(Mandatory = $true)] [string] $ContainerName, [Parameter(Mandatory = $true)] [string] $AppsDirectory, [Parameter(Mandatory = $true)] [string] $ArtifactsDirectory, [Parameter(Mandatory = $true)] [pscredential] $Credential ) $manifests = Get-ITIAppManifestFile -Path $AppsDirectory $appProjectFolders = Sort-AppFoldersByDependencies -appFolders $manifests.Directory.FullName | Get-Item $dependenciesJson = @() $order = 1 foreach ($folder in $appProjectFolders) { Compile-AppInNavContainer -containerName $ContainerName -credential $Credential -appProjectFolder $folder.FullName $appFile = (Get-ChildItem $folder -File -Filter "output/*.app").FullName $appName = (Get-ChildItem $folder -File -Filter "output/*.app").Name $appManifest = Get-Content (Join-Path $folder.FullName "app.json") | ConvertFrom-Json $appId = Get-BcContainerAppInfo -containerName $ContainerName | ? { $_.AppId -eq $appManifest.id } if ($appId) { Publish-NavContainerApp -containerName $ContainerName -credential $Credential -appFile $appFile -skipVerification -sync -install -upgrade } else { Publish-NavContainerApp -containerName $ContainerName -credential $Credential -appFile $appFile -skipVerification -sync -install } Move-Item -Path $appFile -Destination $ArtifactsDirectory $dependenciesJson += New-Object -TypeName PSObject -Property @{OrderNumber = $order; AppName = $appManifest.name; AppFile = $appName; AppVersion = $appManifest.version } $order += 1 } $dependenciesJson | Select-Object -Property OrderNumber, AppName, AppFile, AppVersion | ConvertTo-Json | Out-File ($ArtifactsDirectory + '/dependencies.json') } Export-ModuleMember -Function Install-AppsLocally |