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

Merged
merged 2 commits into from
Jul 15, 2025

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

@alerickson
Copy link
Member

Thanks @o-l-a-v! Is there a small test you can add for this?

@o-l-a-v
Copy link
Contributor Author

o-l-a-v commented Jul 15, 2025

If we can add tests against pwsh.gallery, then yes? Or do you have some other NuGet v3 test service that does the same as Sleet?

@alerickson alerickson mentioned this pull request Jul 15, 2025
14 tasks
@alerickson alerickson added the Test-Robustness Track PRs and issues that don't have the appropriate testing environments for proper unit tests. label Jul 15, 2025
@alerickson
Copy link
Member

We don't have an appropriate repo to test against right now, so you can ignore the tests here as well. I just created a new label 'Test-Robustness' to track these PRs that don't have the appropriate testing environment right now so we can address these tests in the future.

@alerickson alerickson merged commit 5c54a8e into PowerShell:master Jul 15, 2025
14 checks passed
@o-l-a-v o-l-a-v deleted the fix-1840-nugetv3-deps branch July 15, 2025 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Test-Robustness Track PRs and issues that don't have the appropriate testing environments for proper unit tests.
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
2 participants