Sdk: Conflict resolution with packages.config-based projects results in yellow warnings in Solution explorer

Created on 16 Aug 2017  路  7Comments  路  Source: dotnet/sdk

To reproduce:

  1. Create a .NET Framework project targeting .NET 4.7.
  2. Install System.Runtime package and choose "packages.config".
  3. Create a netstandard2.0 project (or 1.5 or 1.6) and reference that from the desktop project.
  4. Unload and reload the solution.

Expect: Builds successfully with no warnings in IDE or solution explorer.
Actual: Builds successfully, but warnings appear in IDE and solution explorer shows yellow warning icon next to references.
image

This is essentially the same as https://github.com/dotnet/sdk/issues/1244 but a different way to get there. In this case it wasn't simple name conflict resolution but the task.

Because conflict resolution removes the items that were directly authored in the csproj by nuget the IDE emits a warning because it cannot reconcile that the winning items should actually be used.

I think we need to come up with a strategy that works for both places and makes the IDE happy with the consolidated references.

/cc @dsplaisted

Bug In PR Needs more tests Urgency-Soon

Most helpful comment

A workaround for this is to add the following to your project file:

  <Target Name="UpdateOriginalItemSpecs" AfterTargets="ResolveAssemblyReferences">
    <ItemGroup>
      <ReferencePath>
        <OriginalItemSpec>%(ReferencePath.FileName)</OriginalItemSpec>
      </ReferencePath>
    </ItemGroup>
  </Target>

All 7 comments

A workaround for this is to add the following to your project file:

  <Target Name="UpdateOriginalItemSpecs" AfterTargets="ResolveAssemblyReferences">
    <ItemGroup>
      <ReferencePath>
        <OriginalItemSpec>%(ReferencePath.FileName)</OriginalItemSpec>
      </ReferencePath>
    </ItemGroup>
  </Target>

Is an alternative solution to remove the system.net.http reference from the console app as it's the lib that requires system.net.http?

Sure, for everything that shows up with the yellow bang you can delete it from the CSProj since it will be provided by the targets. That will also work. That would require you to do so after NuGet adds them there (if they are coming from a package in packages.config based project for example).

Is this the same as #1244 with proposed fix in #1454 ?

It's similar but the fix in #1454 may not be big enough. I think we need to consider any case where we might remove items from Reference. For example: conflict resolution.

I confirm these lines seem to solve the issue:

<Target Name="UpdateOriginalItemSpecs" AfterTargets="ResolveAssemblyReferences">
    <ItemGroup>
      <ReferencePath>
        <OriginalItemSpec>%(ReferencePath.FileName)</OriginalItemSpec>
      </ReferencePath>
    </ItemGroup>
  </Target>
  1. What they do in the project?
  2. May I remove them after the issue disappear?
  1. They are just pretending like all references came from a reference of the form
<Reference Include="System.Net.Http" />

or

<Reference Include="System.Net.Http">
  <HintPath>..\packages\System.Net.Http\4.3.0\lib\net46\System.Net.Http.dll</HintPath>
</Reference>

Even if the reference came from a nuget package resolved through packagereference, or a targets that added the file.

  1. Removing them may make the warnings return (until this issue is fixed). A better workaround is to remove direct references from the project if they were being removed by conflicts (and thus caused this issue), as @chris31389 mentioned.
Was this page helpful?
0 / 5 - 0 ratings

Related issues

dasMulli picture dasMulli  路  3Comments

dsplaisted picture dsplaisted  路  3Comments

clairernovotny picture clairernovotny  路  3Comments

gkhanna79 picture gkhanna79  路  3Comments

natemcmaster picture natemcmaster  路  3Comments