Skip to content

Commit

Permalink
support no dependencies (#3319)
Browse files Browse the repository at this point in the history
Fixes #3318 - check whether any dependencies exists before enumerating
them
Add Stacktrace output to high level functions
Download-BcNuGetPackageToFolder and Get-BcNuGetPackage

---------

Co-authored-by: freddydk <freddydk@users.noreply.github.com>
  • Loading branch information
freddydk and freddydk committed Jan 31, 2024
1 parent 06929bc commit 772f769
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
14 changes: 13 additions & 1 deletion NuGet/Download-BcNuGetPackageToFolder.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ Function Download-BcNuGetPackageToFolder {
[switch] $allowPrerelease
)

try {
$returnValue = $false
$findSelect = $select
if ($select -eq 'LatestMatching') {
Expand All @@ -96,7 +97,13 @@ Function Download-BcNuGetPackageToFolder {
$nuspec | ForEach-Object { Write-Verbose $_ }
$manifest = [xml]$nuspec
$dependenciesErr = ''
foreach($dependency in $manifest.package.metadata.dependencies.GetEnumerator()) {
if ($manifest.package.metadata.PSObject.Properties.Name -eq 'Dependencies') {
$dependencies = $manifest.package.metadata.Dependencies.GetEnumerator()
}
else {
$dependencies = @()
}
foreach($dependency in $dependencies) {
$dependencyVersion = $dependency.Version
$dependencyId = $dependency.Id
$dependencyCountry = ''
Expand Down Expand Up @@ -235,5 +242,10 @@ Function Download-BcNuGetPackageToFolder {
}
return $returnValue
}
catch {
Write-Host -ForegroundColor Red "Error Message: $($_.Exception.Message.Replace("`r",'').Replace("`n",' '))`r`nStackTrace: $($_.ScriptStackTrace)"
throw
}
}
Set-Alias -Name Copy-BcNuGetPackageToFolder -Value Download-BcNuGetPackageToFolder
Export-ModuleMember -Function Download-BcNuGetPackageToFolder -Alias Copy-BcNuGetPackageToFolder
6 changes: 6 additions & 0 deletions NuGet/Get-BcNuGetPackage.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Function Get-BcNuGetPackage {
[switch] $allowPrerelease
)

try {
$feed, $packageId, $packageVersion = Find-BcNugetPackage -nuGetServerUrl $nuGetServerUrl -nuGetToken $nuGetToken -packageName $packageName -version $version -excludeVersions $excludeVersions -verbose:($VerbosePreference -eq 'Continue') -select $select -allowPrerelease:($allowPrerelease.IsPresent)
if (-not $feed) {
Write-Host "No package found matching package name $($packageName) Version $($version)"
Expand All @@ -63,4 +64,9 @@ Function Get-BcNuGetPackage {
return $feed.DownloadPackage($packageId, $packageVersion)
}
}
catch {
Write-Host -ForegroundColor Red "Error Message: $($_.Exception.Message.Replace("`r",'').Replace("`n",' '))`r`nStackTrace: $($_.ScriptStackTrace)"
throw
}
}
Export-ModuleMember -Function Get-BcNuGetPackage
2 changes: 2 additions & 0 deletions ReleaseNotes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ Issue 3301 Run-AlValidation fails running AppsourceCop "Could not load type 'Sys
Give better error message if GitHub CLI, GIT or dotnet is not installed
Issue 3301 Run-AlValidation fails running AppsourceCop "Could not load type 'System.Object' from assembly 'System.Private.CoreLib' (Regression in 6.0.4)
Issue 3313 Strange error in Copy-BcEnvironment
Issue 3318 Download-BcNuGetPackageToFolder fails when no dependencies defined
Add Stacktrace output to high level functions Download-BcNuGetPackageToFolder and Get-BcNuGetPackage

6.0.4
Rename AppInfoCache.json to cache_AppInfo.json (which by default is covered by .gitignore in AL-Go for GitHub)
Expand Down

0 comments on commit 772f769

Please sign in to comment.