【问题标题】:Duplicate 'PackageReference' items found. Remove the duplicate items or use the Update functionality to ensure a consistent restore behaviorDuplicate \'PackageReference\' items found. Remove the duplicate items or use the Update functionality to ensure a consistent restore behavior
【发布时间】:2022-12-02 02:17:52
【问题描述】:

I am using Microsoft Visual Studio Community 2022 (64-bit) - Preview Version 17.3.0 Preview 1.1.

Error

Severity    Code    Description Project File    Line    Suppression State
Error   NU1504  Duplicate 'PackageReference' items found. Remove the duplicate items or use the Update functionality to ensure a consistent restore behavior. The duplicate 'PackageReference' items are: StyleCop.Analyzers 1.1.118, StyleCop.Analyzers 1.1.118; Roslynator.Analyzers 3.2.2, Roslynator.Analyzers 3.2.2.   Shared.DTOs C:\Users\donhu\source\repos\FSH\src\Shared\Shared.DTOs\Shared.DTOs.csproj   1   

Error restoring packages

How to fix it?

【问题讨论】:

    标签: visual-studio nuget visual-studio-2022 nuget-package-restore


    【解决方案1】:

    Temporary solution: add <NoWarn>$(NoWarn);NU1504;NU1505;NU1701</NoWarn> , for example

    Old

    <Project Sdk="Microsoft.NET.Sdk">
      <PropertyGroup>
        <TargetFramework>net6.0</TargetFramework>
        <RootNamespace>FSHTemp.Application</RootNamespace>
        <AssemblyName>FSHTemp.Application</AssemblyName>
      </PropertyGroup>
    ...
    

    new

    <Project Sdk="Microsoft.NET.Sdk">
      <PropertyGroup>
        <TargetFramework>net6.0</TargetFramework>
        <RootNamespace>FSHTemp.Application</RootNamespace>
        <AssemblyName>FSHTemp.Application</AssemblyName>
          <NoWarn>$(NoWarn);NU1504;NU1505;NU1701</NoWarn>
      </PropertyGroup>
    

    result: restore Nuget package success now

    Long-term solution: Update to new version of Visual Studio 2022 (Stability and.or Preview update channels)

    Related: https://github.com/dotnet/sdk/issues/24747

    See more https://github.com/unoplatform/uno.todo/commit/6e442d9b1adb8f990139969413344b135714ed93

    【讨论】:

    • For more clear, edit file *.csproj . You can double click on name of project to open this *.csproj file.
    【解决方案2】:

    This is still a problem when adding PostSharp reference. I created an empty project in the latest version of Visual Studio 2022 (17.4.2) and this warning surfaced as soon as I added the PostSharp reference. When I removed it, the warning went away.

    【讨论】:

      猜你喜欢
      • 2022-12-01
      • 2022-05-17
      • 2021-07-24
      • 1970-01-01
      • 2022-11-20
      • 1970-01-01
      • 2021-07-18
      • 1970-01-01
      • 2015-04-25
      相关资源
      最近更新 更多