豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content

Latest commit

 

History

History
42 lines (31 loc) · 1.04 KB

File metadata and controls

42 lines (31 loc) · 1.04 KB
title NuGet Warning NU1504
description NU1504 warning code
author nkolev92
ms.author nikolev
ms.date 03/31/2022
ms.topic reference
f1_keywords
NU1504

NuGet Warning NU1504

Scenario 1

Duplicate 'PackageReference' items found. Remove the duplicate items or use the Update functionality to ensure a consistent restore behavior. The duplicate 'PackageReference' items are: X 1.0.0, X 2.0.0.

Issue

Sometimes when adding PackageReference items, you may end up adding an item for a particular package multiple times.

Example:

<ItemGroup>
  <PackageReference Include="X" Version="1.0.0" />
</ItemGroup>
...
<!-- Somewhere else in the project file, or another MSBuild file-->
<ItemGroup>
  <PackageReference Include="X" Version="2.0.0" />
</ItemGroup>

This can cause an inconsistent restore behavior.

Solution

Consult the recommendations in the warning message and do one of the following:

  • Remove the duplicate items
  • Use item Update instead of item Include