Skip to content

Duplicate PackageReference includes are handled inconsistently by all restores, leading to unnecessary full restores #9864

@nkolev92

Description

@nkolev92

Take a project such as the following:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net5.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="NuGet.Protocol" Version="5.5.0" />
    <PackageReference Include="NuGet.Protocol" Version="5.6.0" />
  </ItemGroup>

</Project>

Note the duplicate PackageReference declaration. Digging further reveals that different project types and different tools handle it differently.

See the below table for details

Restore Flavor PackageReference declaration
Commandline restore (all) First
Static graph restore (all) First
VS - SDK based projects Last
VS - Legacy PR projects First

This leads to issues as the ones described in dotnet/arcade#5550 (see below repro).

I think logically from an msbuild perspective, we'd expect that the last value is the one that's resolved. This needs investigated and ideally consolidated.
Note that consolidating VS - LEgacy PR projects might be impossible, due to the fact that it's largely in maintenance mode.

See repro below.

cc folks that might have some thoughts around:

@jeffkl @davkean @dsplaisted @zivkan

fyi @sharwell @garath

DuplicateIds.zip

WIP:
Design: https://github.com/NuGet/Home/compare/dev-nkolev92-duplicatesHandling
Implementation: https://github.com/NuGet/NuGet.Client/tree/dev-nkolev92-duplicatePRs

Metadata

Metadata

Assignees

Labels

Area:ErrorHandlingwarnings and errors/log messages & related error codes.Category:Quality WeekIssues that should be considered for quality weekFunctionality:RestorePriority:2Issues for the current backlog.Type:DCRDesign Change Request

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions