Public/Install-P1Package.ps1
function Install-P1Package { <# .Synopsis Get all required packages from PlannerOne NuGet server. .Description Connect to remote repository and get the latest release. .Parameter Package The PlannerOne package list. .Parameter ERP The target ERP to get default packages if not provided in Package list (NAV, AP, REST) .Example # Install PlannerOne server, web and NAV 2016 objects Install-P1Package PlannerOne.Server,PlannerOne.WebApp,PlannerOne.NAV2016Objects .Example # Install PlannerOne REST server and web Install-P1Package -ERP REST #> [cmdletbinding()] param( [string[]] $Package, [string] $ERP ) Process { $feedUrl = Get-FeedUrl if ($feedUrl -eq "") { return } else { try { $plannerOneSource = Get-PackageSource PlannerOne -ErrorAction "SilentlyContinue" } catch {} if ($plannerOneSource -eq $null) { Write-Verbose "Registering $feedUrl as a trusted package source for PlannerOne." Register-PackageSource -Name PlannerOne -Trusted -ProviderName NuGet -Location $feedUrl | Out-Null } } if ($null -eq $Package) { if ($ERP -eq "") { Write-Warning "No package specified and no ERP Specified. Cannot continue." return } $packageSrvWeb = Get-PackageName $P1SrvPackage $ERP $packageWebName = Get-PackageName $P1WebPackage $ERP Write-Warning "No package specified: command will use $packageSrvWeb,$packageWebName" $Package = @( $packageSrvWeb; $packageWebName; ) } Write-Section "Getting PlannerOne packages..." if (Get-Command Install-Package -errorAction SilentlyContinue) { Write-Verbose "Install-Package exists" foreach($Pack in $Package) { Write-Output "Installing $Pack..." Install-Package $Pack -Source $feedUrl | Out-Null $Folder = Get-PackageFolder $Pack Write-OK "Package installed in $Folder" } } else { Write-Output "Install-Package doesn't exist, using NuGet" foreach($Pack in $Package) { Write-Output "Installing $Pack..." NuGet install $Pack -Source $feedUrl } } Write-OK "Packages installed" } } |