Skip to content
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

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

Closed
tsibelman opened this issue Sep 27, 2016 · 35 comments

Comments

@tsibelman
Copy link
Contributor

tsibelman commented Sep 27, 2016

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

@tsibelman tsibelman changed the title Paket is failing to resolve second level dependencies Paket is failing to resolve second level dependencies and failing to add Analyzers section to csproj Sep 27, 2016
@forki
Copy link
Member

forki commented Sep 27, 2016

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
Copy link
Member

forki commented Sep 27, 2016

@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
Copy link
Contributor Author

tsibelman commented Sep 27, 2016

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
Copy link
Member

matthid commented Sep 27, 2016

@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
Copy link
Contributor Author

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
Copy link
Member

matthid commented Sep 27, 2016

@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
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Contributor Author

@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
Copy link
Member

forki commented Sep 28, 2016

what is invalid excatly? don't see it yet

@tsibelman
Copy link
Contributor Author

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
Copy link
Contributor

JohanLarsson commented Sep 28, 2016

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
Copy link
Member

forki commented Sep 28, 2016

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

@tsibelman
Copy link
Contributor Author

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

@forki
Copy link
Member

forki commented Sep 28, 2016

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

@tsibelman
Copy link
Contributor Author

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

@forki
Copy link
Member

forki commented Sep 28, 2016

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
Copy link
Contributor Author

tsibelman commented Sep 28, 2016

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
Copy link
Member

forki commented Sep 28, 2016

yes but that's not important.

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

@forki forki closed this as completed Sep 28, 2016
@forki forki reopened this Sep 28, 2016
@tsibelman
Copy link
Contributor Author

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

What wrong with this ?

@forki
Copy link
Member

forki commented Sep 28, 2016

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
Copy link
Contributor Author

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

@forki
Copy link
Member

forki commented Sep 28, 2016

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

@tsibelman
Copy link
Contributor Author

tsibelman commented Sep 28, 2016

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
Copy link
Member

forki commented Sep 28, 2016

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

@tsibelman
Copy link
Contributor Author

Great, hope it will fix the issue

@forki
Copy link
Member

forki commented Sep 28, 2016

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

@tsibelman
Copy link
Contributor Author

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

@tsibelman
Copy link
Contributor Author

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
Copy link
Member

forki commented Sep 29, 2016

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 added a commit that referenced this issue Sep 29, 2016
@forki
Copy link
Member

forki commented Sep 29, 2016

please retry

@tsibelman
Copy link
Contributor Author

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
Copy link
Member

forki commented Sep 29, 2016

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
#1929 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AADgNBShSazM40ubB91K1pZa5r7sPmPdks5qu2d2gaJpZM4KHgvy
.

@tsibelman
Copy link
Contributor Author

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

@JohanLarsson
Copy link
Contributor

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.

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

No branches or pull requests

4 participants