Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conflict resolution with packages.config-based projects results in yellow warnings in Solution explorer #1499

Closed
ericstj opened this issue Aug 16, 2017 · 7 comments

Comments

@ericstj
Copy link
Member

ericstj commented Aug 16, 2017

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 #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

@ericstj
Copy link
Member Author

ericstj commented Aug 16, 2017

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>

@chris31389
Copy link

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?

@ericstj
Copy link
Member Author

ericstj commented Aug 17, 2017

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).

@nguerrera
Copy link
Contributor

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

@ericstj
Copy link
Member Author

ericstj commented Aug 24, 2017

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.

@gpcaretti
Copy link

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?

@ericstj
Copy link
Member Author

ericstj commented Sep 11, 2017

  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.

@dsplaisted dsplaisted modified the milestones: 2.0.x, 15.5 Oct 2, 2017
@livarcocc livarcocc added the In PR label Oct 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants