2

Mu csproj:

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

it have three framework .net4.6.1 and netstandard2 and .net 5

and system show below message

 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.

I'm confuse about it, their version publickeytoken are same.

enter image description here

full code

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    


enter image description here

How can I deal the waring or set configution to ignore it, thanks.


update :

I've tried set version for each framework, but not work

<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>
Wei Lin
  • 3,591
  • 2
  • 20
  • 52

1 Answers1

2

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

marcpopMSFT says

Can you try removing the references to System.IO.Compression? That file is part of the .net Core runtime and all runtime assemblies are implicitly referenced in your project to make it easier for new developers to use .NET even without having to reference is so you shouldn't need that reference. It looks like it's finding the version in the runtime and the version you directly referenced and giving you a warning that you're essentially referencing it twice.

and I update csproj as below, it can solve my problem

  <ItemGroup Condition=" '$(TargetFramework)' == 'net461'">
    <Reference Include="System.IO.Compression"  />
  </ItemGroup>
Wei Lin
  • 3,591
  • 2
  • 20
  • 52