fsprojects / fsprojects/Paket

External lock does not respect framework version restrictions in referencing project

Open
#3,673 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Description

I am having a solution with a lot of projects which share common dependencies. My projects use the new .NET SDK project style and are multi-targeting as I want to be backwards-compatible with older .NET versions (net35 being the oldest I want to support).

Some of the dependencies in my global paket.dependencies file must be used with framework version restrictions as they are suitable for the older net versions but not for netstandardXX. I absolutely do not want to repeat this dependency conditioning per-project, so I decided to rely on an external paket.lock.

Repro steps
  1. Create a project which would produce the paket.lock file we need to reference in our target project. For simplicity lets call this one "Project X"

    i. In Project X's paket.dependencies add a framework-restricted dependency, for example:

     nuget System.Threading.Tasks.Unofficial framework: net35
    

    ii. Run paket install for "Project X". It's paket.lock file should have an entry like this:

    System.Threading.Tasks.Unofficial (3.1) - restriction: == net35
    
  2. Create a project "Project Y" that would be consuming the paket.lock file created in the above step.
    i. In its paket.dependencies file add:

     external_lock "path/to/Project X/paket.lock"
    

    ii. Run paket install for "Project Y". Examine the generated paket.lock for that project

Expected behavior

The "Project Y"'s paket.lock should have retained the framework restriction established by "Project X":

System.Threading.Tasks.Unofficial (3.1) - restriction: == net35
Actual behavior

Instead, the "Project Y"'s paket.lock does not have the restriction in place:

System.Threading.Tasks.Unofficial (3.1)

The result of this behavior is that if "Project Y" is a multi-targeting project, and is set to build for net35 and netstandard1.3 for example, its paket restore command would fail to install:

path\to\Project.Y.csproj : error NU1202: Package System.Threading.Tasks.Unofficial 3.1.0 is not compatible with netstandard1.3 (.NETStandard,Version=v1.3). Package System.Threading.Tasks.Unofficial 3.1.0 supports:
path\to\Project.Y.csproj : error NU1202: - net35 (.NETFramework,Version=v3.5)
path\to\Project.Y.csproj : error NU1202: - sl3 (Silverlight,Version=v3.0)
path\to\Project.Y.csproj : error NU1202: - sl3-wp (Silverlight,Version=v3.0,Profile=WindowsPhone)
path\to\Project.Y.csproj : error NU1202: - sl4 (Silverlight,Version=v4.0)
path\to\Project.Y.csproj : error NU1202: - sl4-wp71 (Silverlight,Version=v4.0,Profile=WindowsPhone71)
path\to\Project.Y.csproj : error NU1202: - sl5 (Silverlight,Version=v5.0)

Known workarounds

Not really a workaround. You need to not include the external lock and manually define the dependencies you need, but this defeats the purpose of the "external-lock" directive.

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

Reproduce the behavior with the two paket.dependencies files, the external_lock directive, and the generated paket.lock files, starting with paket install and paket restore. Done means Project Y retains the == net35 restriction from Project X and restores successfully for its multi-targeting frameworks.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.