forked from BusinessCentralApps/GenerateBcNuGet
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGenerateNuGetPackages.ps1
24 lines (19 loc) · 1.21 KB
/
GenerateNuGetPackages.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Write-Host "Generate Runtime NuGet Packages"
. (Join-Path $PSScriptRoot "HelperFunctions.ps1")
$appsFolder = Join-Path ([System.IO.Path]::GetTempPath()) ([guid]::NewGuid().ToString())
$apps = @(Copy-AppFilesToFolder -appFiles @("$env:apps".Split(',')) -folder $appsFolder)
$nuGetServerUrl, $githubRepository = GetNuGetServerUrlAndRepository -nuGetServerUrl $env:nuGetServerUrl
$nuGetToken = $env:nuGetToken
foreach($appFile in $apps) {
$appJson = Get-AppJsonFromAppFile -appFile $appFile
# Test whether a NuGet package exists for this app?
$bcContainerHelperConfig.TrustedNuGetFeeds = @(
[PSCustomObject]@{ "url" = $nuGetServerUrl; "token" = $nuGetToken; "Patterns" = @("*.$($appJson.id)") }
)
$package = Get-BcNuGetPackage -packageName $appJson.id -version $appJson.version -select Exact
if (-not $package) {
# If just one of the apps doesn't exist as a nuGet package, we need to create a new indirect nuGet package and build all runtime versions of the nuGet
$package = New-BcNuGetPackage -appfile $appFile -githubRepository $githubRepository
Push-BcNuGetPackage -nuGetServerUrl $nuGetServerUrl -nuGetToken $nuGetToken -bcNuGetPackage $package
}
}