fsprojects / fsprojects/Paket

Duplicate references added when frameworkAssembly and OOB versions of same assembly referenced indirectly

Open
#2,629 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Description

It is possible to end up with two references to the same assembly (e.g. System.Net.Http) but where one comes from a NuGet package using a <frameworkAssembly> element to refer to the version of the assembly that ships as part of some version of the .NET Framework, and where the other comes from a package the supplies a newer OOB version of that same assembly (e.g., the System.Net.Http NuGet package v4.3.2).

When this happens, Paket ends up adding two references to the same assembly, one referring to the reference assembly, and one for the newer OOB version from the NuGet package. This causes ambiguity and build warnings.

Repro steps
  1. Create a new solution in Visual Studio 2017 Update 3 containing an F# project targetting .NET Framework 4.7, and initialize the solution for Paket use.

  2. Use Paket to add a reference to the Microsoft.Rest.ClientRuntime package version 2.3.5. (Later versions such as 2.3.9 don't have this problem by the way, because they no longer have the <frameworkAssembly> reference to System.Net.Http. However, it's easy to end up with v2.3.5 because it's the lowest version that is acceptable to various current Azure Management DLLs

  3. Use Paket to add a reference to the System.Net.Http package version v4.3.2.

Expected behavior

In the project's References node in Solution Explorer there should be a single reference to System.Net.Http and it should be to the OOB version (4.1.1.1) from the System.Net.Http NuGet package, since that is the more recent version. The .fsproj should likewise contain just a single reference.

Actual behavior

There are two references to System.Net.Http visible in the References node in Solution Explorer, and also in the .fsproj file.

Known workarounds

In this specific case you can work around the problem by upgrading to v2.3.9 or later of Microsoft.Rest.ClientRuntime because that no longer contains the <frameworkAssembly> elements. This is not a general workaround, because it relies on the availability of a newer version of the package that doesn't use the problematic feature.

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 Visual Studio 2017 F# project scenario using Microsoft.Rest.ClientRuntime 2.3.5 and System.Net.Http 4.3.2. Inspect the generated .fsproj and References node to trace how the frameworkAssembly and OOB references are both included. Done means the project contains one System.Net.Http reference, selecting the OOB version.

Written by the indexing model from the issue text.

Assessment

Tech stack
fsharp
Domain
build-system
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.