fsprojects / fsprojects/Paket

Can't use Microsoft.CodeAnalysis.Common on .Net 4.5

Open
#1,915 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug resolution
Dominant language
F#
Stars
2.1k
Forks
528
Avg merge
1d 12m
Merged PRs (30d)
54

Description

Description

The Microsoft.CodeAnalysis.Common package reference System.Reflection.Metadata conditionally depending on the framework version and paket doesn't seem to handle it well.

Repro steps
  • Use the following dependencies:
redirects: on
source https://nuget.org/api/v2
nuget Microsoft.CodeAnalysis.Common ~> 1.3.2
  • Run paket install
  • Observe that paket.lock has an incorrect framework restriction on the System.Reflection.Metadata package making it inaccessible to .Net 4.5 (But the package is compatible and referenced by a package that is also compatible) :
System.Reflection.Metadata (1.3) - framework: >= net46, >= netstandard13

It seem to have used only one restriction from Microsoft.CodeAnalysis.Common dependencies instead of merging them all :

    Microsoft.CodeAnalysis.Common (1.3.2)
      ...
      System.Reflection.Metadata (>= 1.2) - framework: portable-net45+win8
      System.Reflection.Metadata (>= 1.3) - framework: >= net46, >= netstandard13
Expected behavior

Transitive dependencies are correctly detected and installed in the project.

Actual behavior

As no reference is created to the transitive dependency the dll isn't included and the code would crash at runtime.

Known workarounds

Using project.json ?

More seriously, I tried to specify a very specific framework for the dependency :

nuget System.Reflection.Metadata framework: portable-net45+win8

But while the lock file now include that one, the msbuild produced still doesn't want to do what I want :

<When Condition="($(TargetFrameworkProfile) == 'Profile7') Or ($(TargetFrameworkProfile) == 'Profile44')">

For now i'll remove the dependency and reference the whole transitive graph by hand.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the paket install with Microsoft.CodeAnalysis.Common 1.3.2 and inspect the generated paket.lock restriction for System.Reflection.Metadata. Trace how the two dependency restrictions are combined, then verify that the resulting lock file and MSBuild output make the transitive dependency available to .NET 4.5.

Written by the indexing model from the issue text.

Assessment

Tech stack
fsharp
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.