I have a Classic Desktop .NET project that references Microsoft.Build 15.1 from NuGet and System.IO.Compression / System.IO.Compression.FileSystem from the .NET SDK / GAC.
I am trying to upgrade it to Microsoft.Build 15.3.
Microsoft.Build 15.3 introduces a dependency on System.IO.Compression 4.1.2.0. Version of System.IO.Compression in the .NET Framework 4.0.0.0.
If I compile this, I get a warning about the inability to resolve assembly conflicts, but my code works:
warning MSB3277: Conflicts were detected between different versions of the same dependent assembly that could not be resolved. These reference conflicts are listed in the build log when detailed log information is specified.
Configuring a multi-line build log for verbose output of this result:
1> There was a conflict between "System.IO.Compression, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" and "System.IO.Compression, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b77a5c561934e089". 1> "System.IO.Compression, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" was chosen because it was primary and "System.IO.Compression, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" was not. 1> References which depend on "System.IO.Compression, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" [C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.IO.Compression.dll]. 1> C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.IO.Compression.dll 1> Project file item includes which caused reference "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.IO.Compression.dll". 1> System.IO.Compression 1> References which depend on "System.IO.Compression, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" [C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\System.IO.Compression.dll]. 1> C:\Temp\CompressionMissingMethod\packages\Microsoft.Build.15.3.409\lib\net46\Microsoft.Build.dll 1> Project file item includes which caused reference "C:\Temp\CompressionMissingMethod\packages\Microsoft.Build.15.3.409\lib\net46\Microsoft.Build.dll". 1> Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL 1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1988,5): warning MSB3277: Found conflicts between different versions of the same dependent assembly that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed.
I can resolve this warning by replacing the SDK / GAC link on System.IO.Compression NuGet link. However, as soon as I do this, code using ZipFile crashes with MissingMethodException when the JIT gets this method.
Unhandled exception: System.MissingMethodException: method not found: 'System.IO.Compression.ZipArchive System.IO.Compression.ZipFile.OpenRead (System.String)'. in CompressionMissingMethod.Program.Main (String [] args)
I put together a very minimal playback example that illustrates this behavior (check the branches).
Is there a way to refer to both Microsoft.Build 15.3 and System.IO.Compression without errors, warnings or exceptions?