fsprojects / Paket

A dependency manager for .NET with support for NuGet packages and Git repositories.
https://fsprojects.github.io/Paket/
MIT License
2.02k stars 520 forks source link

Paket is failing to resolve second level dependencies and failing to add Analyzers section to csproj #1929

Closed tsibelman closed 8 years ago

tsibelman commented 8 years ago

Description

I have reference to package that has a reference to ms code analysis, paket is failing to resolve underlying dependencies for the package and it failing to add Analyzers section to csproj, here is a minimum dependencies file I use

source https://www.nuget.org/api/v2/

framework: net451
redirects: on
content: once
copy_content_to_output_dir: always

nuget Microsoft.Orleans.OrleansCodeGenerator  1.3.0-beta2

Repro steps

Reaname Repo.zip.txt file to Repo.zip and open, you will see sollution with two projects one has paket references other using nuget references, you can check the difference. Repo.zip.txt

Expected behavior

I expect it to behave in the same fashion as nugget

forki commented 8 years ago

mhm.

https://www.nuget.org/packages/Microsoft.CodeAnalysis.Common/2.0.0-beta3 is tricky. looks like Paket prefers Portable Class Library (.NETFramework 4.5, Windows 8.0) here.

@matthid ideas?!

forki commented 8 years ago

@tsibelman as workaround until we find a solution you can add the analyzer package manually in deps and references file. Not nice, but at least you can keep working for now.

tsibelman commented 8 years ago

It not just analyzer package but all of it dependencies, BTW I noticed following, when I remove framework restriction the reference looks like this

System.Reflection.Metadata.dll

  <Choose>
    <When Condition="($(TargetFrameworkIdentifier) == '.NETStandard' And ($(TargetFrameworkVersion) == 'v1.3' Or $(TargetFrameworkVersion) == 'v1.4' Or $(TargetFrameworkVersion) == 'v1.5' Or $(TargetFrameworkVersion) == 'v1.6')) Or ($(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.6' Or $(TargetFrameworkVersion) == 'v4.6.1' Or $(TargetFrameworkVersion) == 'v4.6.2' Or $(TargetFrameworkVersion) == 'v4.6.3'))">
      <ItemGroup>
        <Reference Include="System.Reflection.Metadata">
          <HintPath>..\packages\System.Reflection.Metadata\lib\netstandard1.1\System.Reflection.Metadata.dll</HintPath>
          <Private>True</Private>
          <Paket>True</Paket>
        </Reference>
      </ItemGroup>
    </When>
  </Choose>

As you can see TargetFrameworkVersion 4.5 and 4.5.1 are not here, but according to https://docs.microsoft.com/en-us/dotnet/articles/standard/library 1.1 is equvalent to .net 4.5

matthid commented 8 years ago

@forki We prefer anything to netstandard because people don't like it. Nuget obviously prefers netstandard (which makes sense as it is the vnext of portable).

Creating the test cases is still on my todo list. This is a perfect example for a test-case...

tsibelman commented 8 years ago

Is it possible the issue is in these lines from Paket.Core/FrameworkHandling.fs?

 DotNetFramework FrameworkVersion.V4_5 -> [ DotNetFramework FrameworkVersion.V4; DotNetStandard DotNetStandardVersion.V1_1 ]
        | DotNetFramework FrameworkVersion.V4_5_1 -> [ DotNetFramework FrameworkVersion.V4_5; DotNetStandard DotNetStandardVersion.V1_2 ]
        | DotNetFramework FrameworkVersion.V4_5_2 -> [ DotNetFramework FrameworkVersion.V4_5_1; DotNetStandard DotNetStandardVersion.V1_2 ]
        | DotNetFramework FrameworkVersion.V4_5_3 -> [ DotNetFramework FrameworkVersion.V4_5_2; DotNetStandard DotNetStandardVersion.V1_2 ]
        | DotNetFramework FrameworkVersion.V4_6 -> [ DotNetFramework FrameworkVersion.V4_5_3; DotNetStandard DotNetStandardVersion.V1_3 ]
        | DotNetFramework FrameworkVersion.V4_6_1 -> [ DotNetFramework FrameworkVersion.V4_6; DotNetStandard DotNetStandardVersion.V1_4 ]
        | DotNetFramework FrameworkVersion.V4_6_2 -> [ DotNetFramework FrameworkVersion.V4_6_1; DotNetStandard DotNetStandardVersion.V1_5 ]
        | DotNetFramework FrameworkVersion.V4_6_3 -> [ DotNetFramework FrameworkVersion.V4_6_2; DotNetStandard DotNetStandardVersion.V1_6 ]

If I undertstand it correctly it says that Framework v 4.5.1 contains framework 4.5 and netstandard v1.2 But it also should contain netstandard v1.1

matthid commented 8 years ago

@tsibelman That's fine because we go through this recursively to find compatible frameworks. It's just that our algorithm to give penalty to specific frameworks is giving netstandard a lot of penalty because we don't want to download the internet...

tsibelman commented 8 years ago

I see, I do not know F#, but I just tried to understand why in the sample I gave above condition do not contain any reference to 4.5.* versions, it looks that it should.

tsibelman commented 8 years ago

I mean here:

<Choose>
    <When Condition="($(TargetFrameworkIdentifier) == '.NETStandard' And ($(TargetFrameworkVersion) == 'v1.3' Or $(TargetFrameworkVersion) == 'v1.4' Or $(TargetFrameworkVersion) == 'v1.5' Or $(TargetFrameworkVersion) == 'v1.6')) Or ($(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.6' Or $(TargetFrameworkVersion) == 'v4.6.1' Or $(TargetFrameworkVersion) == 'v4.6.2' Or $(TargetFrameworkVersion) == 'v4.6.3'))">
      <ItemGroup>
        <Reference Include="System.Reflection.Metadata">
          <HintPath>..\packages\System.Reflection.Metadata\lib\netstandard1.1\System.Reflection.Metadata.dll</HintPath>
          <Private>True</Private>
          <Paket>True</Paket>
        </Reference>
      </ItemGroup>
    </When>
  </Choose>
tsibelman commented 8 years ago

@forki by the way it perfectly fine that paket chooses Portable Class Library (.NETFramework 4.5, Windows 8.0) it not the issue here, the problem is with invalid conditions in project references

forki commented 8 years ago

what is invalid excatly? don't see it yet

tsibelman commented 8 years ago

System.Reflection.Metadata.dll is of netstandard1.1 it means it can be consumed by all of these frameworks 4.5, 4.5.1, 4.6,4.6.1,4.6.2 and beyond

But in this condition it allows consumption of only for these

($(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.6' Or $(TargetFrameworkVersion) == 'v4.6.1' Or $(TargetFrameworkVersion) == 'v4.6.2' Or $(TargetFrameworkVersion) == 'v4.6.3'))

JohanLarsson commented 8 years ago

I tried installing Microsoft.CodeAnalysis.CSharp.Workspaces and the lock file did not look right, too few dependencies liste, think it is related.

I can try to PR a failing test but don't think I can fix it as I don't know f#.

forki commented 8 years ago

where is that System.Reflection.Metadata snippet from? It's not in the sample!?

tsibelman commented 8 years ago

It happens when I try to remove framework: net451 from dependency file

forki commented 8 years ago

wow this is another strange case. related to @matthid's #567

tsibelman commented 8 years ago

To me this discrimination of 4.5.1 looks like a root cause of the original bug

forki commented 8 years ago

Ok let's analyze by hand:

Microsoft.Orleans.OrleansCodeGenerator
  => Microsoft.CodeAnalysis.CSharp
    => Microsoft.CodeAnalysis.Common

brings us to https://www.nuget.org/packages/Microsoft.CodeAnalysis.Common/1.3.2

this one specifies that it needs

  System.Reflection.Metadata (>= 1.2) - framework: portable-net45+win8
  System.Reflection.Metadata (>= 1.3) - framework: >= net46, >= netstandard13

so from here on netstandard11 is filtered out.

tsibelman commented 8 years ago

I downloaded System.Reflection.Metadata package looks like it contains internaly two versions of dll one in portable folder and one in netstandard11 folder. It do not contain netstandard13 version at all.

forki commented 8 years ago

yes but that's not important.

Important is that Microsoft.CodeAnalysis.Common only requires System.Reflection.Metadata for netstandard 1.3 and higher

tsibelman commented 8 years ago

But portable-net45+win8 requires System.Reflection.Metadata (>= 1.2.0).

What wrong with this ?

forki commented 8 years ago

that one is indeed a bug and an update is under way. with the next version it will install that lib for portable-net45-win8

but this update doesn't solve your issue yet. the problem is still https://www.nuget.org/packages/Microsoft.CodeAnalysis.Common/1.3.2

currently we only install portable libs for net45 when we don't find other specifications. but this one has net standard specifications. so we assume these people don't want it to install System.Reflection.Metadata

tsibelman commented 8 years ago

Yes it did not solved the as you predicted, looks like you need to take netstandard if all other options do not fit.

forki commented 8 years ago

no it clearly states that it doesn't need it. @matthid what do you say?

tsibelman commented 8 years ago

As I understood it It says that for frameworks fiting portable-net45+win8 it should bring System.Reflection.Metadata (>= 1.2)

I use framework: net451 so it in range of portable-net45+win8

Maybe this doc will help http://docs.nuget.org/ndocs/schema/target-frameworks

forki commented 8 years ago

ah that doc states portable-net45+win8 is a alias for netstandard11 we could make use of that definition

tsibelman commented 8 years ago

Great, hope it will fix the issue

forki commented 8 years ago

new version released. you can run "paket update -f" (in order to clear then cache) and it should install that package.

tsibelman commented 8 years ago

It did not fixed, also I looked into your commit I don't see that you changed anything important in there

tsibelman commented 8 years ago

I cleaned the caches and tried again on new project still no change.

As you wrote Microsoft.codeanalysis.common.1.3.2 package specifies dependencies for netstandard1.3 and portable-net45%2Bwin8

So I performed following experiment, I change my project version from 4.5.1 to 4.5 and it all worked perfectly. So it looks like you do not consider 4.5.1 framework as a super set of portable-net45%2Bwin8 for a question of dependencies resolution.

forki commented 8 years ago

Yeah I changed another thing so that it works for 4.5.1 as well. Integration tests are running. So expect release in 30 min (if things are still green)

forki commented 8 years ago

please retry

tsibelman commented 8 years ago

It did not helped when I remove line framework: net451 from dependency file

I see following:

Microsoft.CodeAnalysis.Common in packet.locket has dependency System.Reflection.Metadata (>= 1.2) - framework: net45, >= netstandard11, portable-net45+win8

In csproj I see following

 <When Condition="($(TargetFrameworkIdentifier) == '.NETStandard' And ($(TargetFrameworkVersion) == 'v1.1' Or $(TargetFrameworkVersion) == 'v1.2' Or $(TargetFrameworkVersion) == 'v1.3' Or $(TargetFrameworkVersion) == 'v1.4' Or $(TargetFrameworkVersion) == 'v1.5' Or $(TargetFrameworkVersion) == 'v1.6')) Or ($(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.6' Or $(TargetFrameworkVersion) == 'v4.6.1' Or $(TargetFrameworkVersion) == 'v4.6.2' Or $(TargetFrameworkVersion) == 'v4.6.3'))">
      <ItemGroup>
        <Reference Include="System.Reflection.Metadata">
          <HintPath>..\packages\System.Reflection.Metadata\lib\netstandard1.1\System.Reflection.Metadata.dll</HintPath>
          <Private>True</Private>
          <Paket>True</Paket>
        </Reference>
      </ItemGroup>
    </When>

As you can see 4.5.1 is still not there

forki commented 8 years ago

It works for me. Are you sure you run update -f with latest paket?

Am 29.09.2016 09:23 schrieb "Michael Tsibelman" notifications@github.com:

It did not helped when I remove line framework: net451 from dependency file

I see following:

Microsoft.CodeAnalysis.Common in packet.locket has dependency System.Reflection.Metadata (>= 1.2) - framework: net45, >= netstandard11, portable-net45+win8

In csproj I see following

..\packages\System.Reflection.Metadata\lib\netstandard1.1\System.Reflection.Metadata.dll True True

As you can see 4.5.1 is still not there

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/fsprojects/Paket/issues/1929#issuecomment-250390680, or mute the thread https://github.com/notifications/unsubscribe-auth/AADgNBShSazM40ubB91K1pZa5r7sPmPdks5qu2d2gaJpZM4KHgvy .

tsibelman commented 8 years ago

Yes update -f helped now it works, thank you.

JohanLarsson commented 8 years ago

The lock file looks better after running update -f now. Running on nuget Microsoft.CodeAnalysis.CSharp.Workspaces 1.2.1 still breaks something though. Very likely that the packages are broken.