Skip to content

Commit d44c7e7

Browse files
lktraserfreddydk
andauthored
EarliestMatching search for Download-BcNuGetPackageToFolder (#3765)
For runtime creation / OnPrem deployments it's usually needed to retrieve runtime packages with the earliest matching version. This approach feels almost too easy so please point out if I missed something but it seemed to resolve the way I want it to. #3590 --------- Co-authored-by: Freddy Kristiansen <[email protected]>
1 parent 922b356 commit d44c7e7

3 files changed

+12
-6
lines changed

NuGet/Download-BcNuGetPackageToFolder.ps1

+9-5
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
.PARAMETER select
2020
Select the package to download if more than one package is found matching the name and version
2121
- Earliest: Select the earliest version
22+
- EarliestMatching: Select the earliest version matching the already installed dependencies
2223
- Latest: Select the latest version (default)
2324
- LatestMatching: Select the latest version matching the already installed dependencies
2425
- Exact: Select the exact version
@@ -57,7 +58,7 @@ Function Download-BcNuGetPackageToFolder {
5758
[Parameter(Mandatory=$false)]
5859
[string] $version = '0.0.0.0',
5960
[Parameter(Mandatory=$false)]
60-
[ValidateSet('Earliest','Latest','LatestMatching','Exact','Any')]
61+
[ValidateSet('Earliest','EarliestMatching','Latest','LatestMatching','Exact','Any')]
6162
[string] $select = 'Latest',
6263
[Parameter(Mandatory=$true)]
6364
[alias('appSymbolsFolder')]
@@ -81,6 +82,9 @@ try {
8182
if ($select -eq 'LatestMatching') {
8283
$findSelect = 'Latest'
8384
}
85+
if ($select -eq 'EarliestMatching') {
86+
$findSelect = 'Earliest'
87+
}
8488
$excludeVersions = @()
8589
if ($checkLocalVersion) {
8690
# Format Publisher.Name[.Country][.symbols][.AppId]
@@ -246,11 +250,11 @@ try {
246250
Write-Host "WARNING: NuGet package $packageId (version $packageVersion) requires $dependencyCountry application. You have $installedCountry application installed"
247251
}
248252
if ($dependenciesErr) {
249-
if ($select -ne 'LatestMatching') {
253+
if (@('LatestMatching', 'EarliestMatching') -notcontains $select) {
250254
throw $dependenciesErr
251255
}
252256
else {
253-
# If we are looking for the latest matching version, then we can try to find another version
257+
# If we are looking for the earliest/latest matching version, then we can try to find another version
254258
Write-Host "WARNING: $dependenciesErr"
255259
break
256260
}
@@ -260,11 +264,11 @@ try {
260264
# Downloading Microsoft packages for a specific version
261265
$dependencyVersion = $version
262266
}
263-
$returnValue += Download-BcNuGetPackageToFolder -nuGetServerUrl $nuGetServerUrl -nuGetToken $nuGetToken -packageName $dependencyId -version $dependencyVersion -folder $package -copyInstalledAppsToFolder $copyInstalledAppsToFolder -installedPlatform $installedPlatform -installedCountry $installedCountry -installedApps @($installedApps+$returnValue) -downloadDependencies $downloadDependencies -verbose:($VerbosePreference -eq 'Continue') -select $select -allowPrerelease:$allowPrerelease -checkLocalVersion
267+
$returnValue += Download-BcNuGetPackageToFolder -nuGetServerUrl $nuGetServerUrl -nuGetToken $nuGetToken -packageName $dependencyId -version $dependencyVersion -folder $package -copyInstalledAppsToFolder $copyInstalledAppsToFolder -installedPlatform $installedPlatform -installedCountry $installedCountry -installedApps @($installedApps + $returnValue) -downloadDependencies $downloadDependencies -verbose:($VerbosePreference -eq 'Continue') -select $select -allowPrerelease:$allowPrerelease -checkLocalVersion
264268
}
265269
}
266270
if ($dependenciesErr) {
267-
# If we are looking for the latest matching version, then we can try to find another version
271+
# If we are looking for the earliest/latest matching version, then we can try to find another version
268272
$excludeVersions += $packageVersion
269273
Remove-Item -Path $package -Recurse -Force
270274
continue

NuGet/Publish-BcNuGetPackageToContainer.ps1

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
.PARAMETER select
1919
Select the package to download if more than one package is found matching the name and version
2020
- Earliest: Select the earliest version
21+
- EarliestMatching: Select the earliest version matching the already installed dependencies
2122
- Latest: Select the latest version (default)
2223
- LatestMatching: Select the latest version matching the already installed dependencies
2324
- Exact: Select the exact version
@@ -49,7 +50,7 @@ Function Publish-BcNuGetPackageToContainer {
4950
[Parameter(Mandatory=$false)]
5051
[string] $version = '0.0.0.0',
5152
[Parameter(Mandatory=$false)]
52-
[ValidateSet('Earliest','Latest','LatestMatching','Exact','Any')]
53+
[ValidateSet('Earliest', 'EarliestMatching', 'Latest', 'LatestMatching', 'Exact', 'Any')]
5354
[string] $select = 'Latest',
5455
[string] $containerName = "",
5556
[Hashtable] $bcAuthContext,

ReleaseNotes.txt

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Issue 3762 Give Option to Choose SQL PowerShell Module When Restoring From BacPac
33
There are instances where sqlps does not work as expected when it is installed. This change adds a switch parameter, useSqlServerModule, to Restore-BcDatabaseFromArtifacts, New-NavContainer, and the BcContainerHelper config file.
44
Issue 1303 from AL-Go repository - renew federated token when access token needs renewal (works only for GitHub at this time)
5+
Issue 3590 EarliestMatching select option added to Download-BcNuGetPackageToFolder
56
Regression when from PR 3760 - Push-BcNuGetPackage doesn't work on PowerSHell 5
67

78
6.0.29

0 commit comments

Comments
 (0)