Skip to content

NuGet v3 dependencies - Fix #1840 #1841

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

o-l-a-v
Copy link
Contributor

@o-l-a-v o-l-a-v commented Jul 4, 2025

PR Summary

I wrongfully checked for property @id both in dependencyGroups and dependencies, but that property is not mandatory as pointed out by @fflaten.

This should fix #1840 by:

  • Don't check for any property in dependencyGroups.
  • Check for property id instead of @id for dependencies.

Tested like so:

# Build the project
& <project_root>\build.ps1 -Clean -Build -BuildFramework net472

# Import the built DLL
Import-Module -Name '<project_root>\out\Microsoft.PowerShell.PSResourceGet\Microsoft.PowerShell.PSResourceGet.dll'

# Register necessary resource repositories if not present
foreach ($Repository in 'pwsh.gallery', 'preview.pwsh.gallery') {
    if ((Get-PSResourceRepository).Where{$_.'Name' -eq $Repository}.'Count' -le 0) {
        Write-Information -InformationAction 'Continue' -MessageData (
            '"{0}" was not already registered.' -f $Repository
        )
        Register-PSResourceRepository -Name $Repository `
            -Uri ('https://{0}/index.json' -f $Repository) -ApiVersion 'v3' -Priority 60
    }
    else {
        Write-Information -InformationAction 'Continue' -MessageData (
            '"{0}" was already registered.' -f $Repository
        )
    }
}

# Find a package we know will have dependencies
## pwsh.gallery
(Find-PSResource -Repository 'pwsh.gallery' -Name 'Az').'Dependencies'
## preview.pwsh.gallery
(Find-PSResource -Repository 'preview.pwsh.gallery' -Name 'Az').'Dependencies'

# Check what Save-PSResource would do
Save-PSResource -Repository 'pwsh.gallery' -TrustRepository -Name 'Az' -WhatIf

PR Context

PR Checklist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[1.2.0-preview1] TryConvertFromJson: Cannot parse PSResourceInfo from json object with error
1 participant