OneGet / oneget

PackageManagement (aka OneGet) is a package manager for Windows
MIT License
2.38k stars 190 forks source link

Get-Package from NuGet is missing crucial dependency information #370

Open Jaykul opened 6 years ago

Jaykul commented 6 years ago

When I Install-Package and then Get-Package the returned object has a Dependencies property, but it has lost the crucial <group> information!

For instance, if we:

$Dependencies = Install-Package SemanticVersion -Source NuGet -Scope CurrentUser
$Package = Get-Package SemanticVersion -ProviderName NuGet
$Package.Dependencies

We get:

nuget:NETStandard.Library/1.6.1
nuget:NETStandard.Library/1.6.1
nuget:NETStandard.Library/1.6.1
nuget:NETStandard.Library/1.6.1
nuget:NETStandard.Library/1.6.1

But I can't tell:

As an aside:

clearly the author of this package has done a terrible job of packaging (he's shipping separate builds for "netstandard1.6", "netstandard1.5", "netstandard1.4", "netstandard1.3", "netstandard1.2" ... but they all supposedly depend on the same NETStandard.Library?

Probably we should have only:

  1. net standard 1.2 version (lowest supported .net standard version)
  2. net standard 2.0 version (no longer requires the NetStandard.Library)
  3. net framework 4.5.2 version (lowest version supported in .Net full framework)

Regardless.

If my goal is to use this SemanticVersion assembly in PowerShell. I need one of those three versions:

  1. In PowerShell 6.0 I need the .NETStandard1.2 version
  2. In PowerShell 6.1 I can use the .NETStandard2.0 version
  3. In PowerShell 5.1 and lower, I can use the .NETFramework 4.5.2 version

For one of them, I have a dependency I need to import first. But for the other two, I have no dependencies!

We need for the .Dependencies property to preserve the targetFramework grouping, or it's basically useless, and I'm going to have to go pull the .nuspec file out of the package myself in order to figure out the dependency.

LanceUMatthews commented 5 years ago

I was about to open an issue for what I observed with the Microsoft.Build.Utilities.Core package...

PS> (Get-Package -Name 'Microsoft.Build.Utilities.Core').Dependencies
nuget:Microsoft.Build.Framework/16.0.461
nuget:Microsoft.VisualStudio.Setup.Configuration.Interop/1.16.30
nuget:System.Collections.Immutable/1.5.0
nuget:Microsoft.Build.Framework/16.0.461
nuget:Microsoft.Win32.Registry/4.3.0
nuget:System.Collections.Immutable/1.5.0
nuget:System.Text.Encoding.CodePages/4.0.1

The Microsoft.Build.Framework and System.Collections.Immutable dependencies are repeated. Looking at the <dependencies> element of the .nuspec file...

<dependencies>
    <group targetFramework=".NETFramework4.7.2">
        <dependency id="Microsoft.Build.Framework" version="16.0.461" exclude="Build,Analyzers" />
        <dependency id="Microsoft.VisualStudio.Setup.Configuration.Interop" version="1.16.30" exclude="Build,Analyzers" />
        <dependency id="System.Collections.Immutable" version="1.5.0" exclude="Build,Analyzers" />
    </group>
    <group targetFramework=".NETStandard2.0">
        <dependency id="Microsoft.Build.Framework" version="16.0.461" exclude="Build,Analyzers" />
        <dependency id="Microsoft.Win32.Registry" version="4.3.0" exclude="Build,Analyzers" />
        <dependency id="System.Collections.Immutable" version="1.5.0" exclude="Build,Analyzers" />
        <dependency id="System.Text.Encoding.CodePages" version="4.0.1" exclude="Build,Analyzers" />
    </group>
</dependencies>

...we see the same dependencies in the same order, with Microsoft.Build.Framework and System.Collections.Immutable common to both groups. It seems that the Dependencies property is just spitting out the <dependency /> elements it finds but, just as you say, without the needed context of the enclosing <group>.

SydneyhSmith commented 5 years ago

@LanceUMatthews Thanks for following up on this issue, we are able to repro