【问题标题】:Same version and publickeytoken but show "warning MSB3243: No way to resolve conflict between System.IO.Compression, Version=4.1.3.0"相同的版本和 publickeytoken 但显示“警告 MSB3243:无法解决 System.IO.Compression 之间的冲突,版本 = 4.1.3.0”
【发布时间】:2021-03-18 05:56:18
【问题描述】:

亩csproj:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFrameworks>net461;netstandard2.0;net5.0</TargetFrameworks>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="System.IO.Compression" />
  </ItemGroup>
</Project>

它有 .net4.6.1 和 netstandard2 和 .net 5 三个框架

系统显示如下信息

 warning MSB3243: No way to resolve conflict between "System.IO.Compression, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" and "System.IO.Compression". Choosing "System.IO.Compression, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" arbitrarily.

我很困惑,他们的版本 publickeytoken 是一样的。

完整代码

Severity    Code    Description Project File    Line    Suppression State
Warning MSB3245 Could not resolve this reference. Could not locate the assembly "System.IO.Compression". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.    MiniExcelLibs   C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets   2182    
Warning MSB3245 Could not resolve this reference. Could not locate the assembly "System.IO.Compression". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.    MiniExcelLibs   C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets   2182    
Warning MSB3243 No way to resolve conflict between "System.IO.Compression, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" and "System.IO.Compression". Choosing "System.IO.Compression, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" arbitrarily. MiniExcelLibs   C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets   2182    
Warning MSB3243 No way to resolve conflict between "System.IO.Compression, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" and "System.IO.Compression". Choosing "System.IO.Compression, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" arbitrarily. MiniExcelLibs   C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets   2182    


如何处理警告或设置配置以忽略它,谢谢。


更新:

我已经尝试为每个框架设置版本,但不起作用

<Project Sdk="Microsoft.NET.Sdk">
  <ItemGroup Condition=" '$(TargetFramework)' == 'net461'">
    <Reference Include="System.IO.Compression" Version="4.1.3.0"  />
  </ItemGroup>
  <ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0'">
    <Reference Include="System.IO.Compression" Version="4.1.3.0"  />
  </ItemGroup>
  <ItemGroup Condition=" '$(TargetFramework)' == 'net5.0'">
    <Reference Include="System.IO.Compression" Version="5.0.0.0"  />
  </ItemGroup>
</Project>

【问题讨论】:

    标签: .net


    【解决方案1】:

    https://github.com/dotnet/sdk/issues/16407

    marcpopMSFT

    您可以尝试删除对 System.IO.Compression 的引用吗?该文件是 .net Core 运行时的一部分,并且所有运行时程序集都在您的项目中隐式引用,以使新开发人员即使无需引用也可以更轻松地使用 .NET,因此您不需要该引用。它看起来像是在运行时找到版本和您直接引用的版本,并警告您实际上是在引用它两次。

    我更新csproj如下,它可以解决我的问题

      <ItemGroup Condition=" '$(TargetFramework)' == 'net461'">
        <Reference Include="System.IO.Compression"  />
      </ItemGroup>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-20
      • 2017-01-31
      • 2022-10-25
      • 2014-08-15
      相关资源
      最近更新 更多