Skip to content

Incorrect conditional references created for group dependencies #1505

Closed

Description

@kevinbosman

Case in point:
NuGet package EasyNetQ v0.53.6.419 has the following nuspec dependency list:

    <dependencies>
      <group>
        <dependency id="RabbitMQ.Client" version="[3.5.7, ]" />
        <dependency id="Microsoft.Bcl" version="1.1.10" />
        <dependency id="Microsoft.Bcl.Async" version="1.0.168" />
        <dependency id="Microsoft.Bcl.Build" version="1.0.21" />
      </group>
      <group targetFramework=".NETFramework4.5">
        <dependency id="RabbitMQ.Client" version="[3.5.7, ]" />
      </group>
    </dependencies>

The desired behaviour is that framework >= net45 should NOT need the references to Microsoft.Bcl.*; everything else should.

Given my paket.dependencies contains:

nuget EasyNetQ ~> 0.53.6 framework: >= net45

Paket v2.51.7 incorrectly creates the following reference conditionals in the project file, which are exactly inverted:

  <Choose>
    <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.5.1' Or $(TargetFrameworkVersion) == 'v4.5.2' Or $(TargetFrameworkVersion) == 'v4.5.3' Or $(TargetFrameworkVersion) == 'v4.6' Or $(TargetFrameworkVersion) == 'v4.6.1')">
      <ItemGroup>
        <Reference Include="Microsoft.Threading.Tasks.Extensions.Desktop">
          <HintPath>..\packages\Microsoft.Bcl.Async\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll</HintPath>
          <Private>True</Private>
          <Paket>True</Paket>
        </Reference>
        <Reference Include="Microsoft.Threading.Tasks.Extensions">
          <HintPath>..\packages\Microsoft.Bcl.Async\lib\net40\Microsoft.Threading.Tasks.Extensions.dll</HintPath>
          <Private>True</Private>
          <Paket>True</Paket>
        </Reference>
        <Reference Include="Microsoft.Threading.Tasks">
          <HintPath>..\packages\Microsoft.Bcl.Async\lib\net40\Microsoft.Threading.Tasks.dll</HintPath>
          <Private>True</Private>
          <Paket>True</Paket>
        </Reference>
        <Reference Include="System.Net">
          <Paket>True</Paket>
        </Reference>
      </ItemGroup>
    </When>
  </Choose>

paket.lock also incorrectly contains:

    EasyNetQ (0.53.6.419) - framework: >= net45
      Microsoft.Bcl (>= 1.1.10)
      Microsoft.Bcl.Async (>= 1.0.168)
      Microsoft.Bcl.Build (>= 1.0.21)
      RabbitMQ.Client (>= 3.5.7)
    Microsoft.Bcl (1.1.10) - framework: >= net45
      Microsoft.Bcl.Build (>= 1.0.14)
    Microsoft.Bcl.Async (1.0.168) - framework: >= net45
      Microsoft.Bcl (>= 1.1.8)
    Microsoft.Bcl.Build (1.0.21) - import_targets: false, framework: >= net45
    RabbitMQ.Client (3.6.1) - framework: >= net45

For completeness, the project file also correctly contains:

  <Choose>
    <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.5.1' Or $(TargetFrameworkVersion) == 'v4.5.2' Or $(TargetFrameworkVersion) == 'v4.5.3' Or $(TargetFrameworkVersion) == 'v4.6' Or $(TargetFrameworkVersion) == 'v4.6.1')">
      <ItemGroup>
        <Reference Include="EasyNetQ">
          <HintPath>..\packages\EasyNetQ\lib\net45\EasyNetQ.dll</HintPath>
          <Private>True</Private>
          <Paket>True</Paket>
        </Reference>
      </ItemGroup>
    </When>
  </Choose>
   <Choose>
    <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.5.1' Or $(TargetFrameworkVersion) == 'v4.5.2' Or $(TargetFrameworkVersion) == 'v4.5.3' Or $(TargetFrameworkVersion) == 'v4.6' Or $(TargetFrameworkVersion) == 'v4.6.1')">
      <ItemGroup>
        <Reference Include="RabbitMQ.Client">
          <HintPath>..\packages\RabbitMQ.Client\lib\net45\RabbitMQ.Client.dll</HintPath>
          <Private>True</Private>
          <Paket>True</Paket>
        </Reference>
      </ItemGroup>
    </When>
  </Choose>

Activity

  1. kevinbosman commented on Mar 9, 2016

    @kevinbosman
    ContributorAuthor

    This is pure speculation before looking at any code, but is it possible that targetFramework parsing is inconsistent with NuGet parsing?

    Notice in the nuspec that targetFramework=".NETFramework4.5". This works perfectly in NuGet as per the framework parsing rules defined here: https://github.com/NuGet/NuGet.Client/blob/dev/src/NuGet.Core/NuGet.Frameworks/NuGetFrameworkFactory.cs

  2. forki commented on Mar 9, 2016

    @forki
    Member

    could you please retry? thx

  3. kevinbosman commented on Mar 9, 2016

    @kevinbosman
    ContributorAuthor

    No improvement after paket update on v2.51.9 :/

  4. forki commented on Mar 9, 2016

    @forki
    Member

    Are you sure? Did you try to run "paket update -f"?
    On Mar 9, 2016 13:19, "Kevin Bosman" notifications@github.com wrote:

    No improvement after paket update on v2.51.9 :/

    —
    Reply to this email directly or view it on GitHub
    #1505 (comment).

  5. kevinbosman commented on Mar 9, 2016

    @kevinbosman
    ContributorAuthor

    Ah, ok it fixes it when I do update -f, but then puts bcl back when I then do a straight update thereafter

  6. forki commented on Mar 9, 2016

    @forki
    Member

    really?

    just to make sure there is no cache issue.

    Can you please run paket clear-cache and try the update again?

  7. kevinbosman commented on Mar 9, 2016

    @kevinbosman
    ContributorAuthor

    Thank you. Yes, it must have been a cache issue... I have 2 sources defined & -f was consistently only refreshing one of them, straight update must have been using the other - which is odd in itself, but possibly coincidental.
    I didn't actually run clear-cache, but after I listed each source individually in turn it came right.
    Thanks for fixing this so quickly! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions