Skip to content

Conflict Resolution is incorrectly assuming that all of the platform assemblies are referenced which is causing build time errors #2221

Closed
@joperezr

Description

@joperezr

Conflict resolution target will blindly assume that all of the platform assemblies are referenced (which is not necessarily true for all of the non-facade ones)

This can lead to problems like the one that this user faced. Basically the scenario is having a 4.7.2 console project that references the platform's System.Net.Http, and that also references System.Net.Http package (either transitively or directly). This will cause that first, ResolveNuGetPackageAssets target will remove the reference to the platform one by assuming that the NuGet package reference should win (which is also incorrect and I'm logging a separate bug for that on NuGet) and then the _HandlePackageFileConflicts target will remove the package reference to System.Net.Http since it will see that the platform's assembly version is higher, even though it is not referenced any longer. That leads to compilation errors when trying to use a type from System.Net.Http, since at the time of calling the compiler, no System.Net.Http will be referenced.

Here are some simple repro steps:
1.- Create a 4.7.2 Console App using the latest version of VS.
2.- Edit your project.csproj file to include these lines:

  <ItemGroup>
    <Reference Include="System.Net.Http" />
    <PackageReference Include="System.Net.Http" Version="4.3.3" />
  </ItemGroup>

3.- Edit your Program.cs file to use S.N.Http like:

using System.Net.Http;
...
static void Main(string[] args)
        {
            HttpClient client = new HttpClient();

4.- Try to build.

Expected:
Build should work since you are clearly referencing System.Net.Http

Actual:
Can't find System.Net.Http.dll

cc: @ericstj @nguerrera @dsplaisted @AlexGhiondea

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions