'System.IO.Compression is missing in self-contained builds on .NET 6

For some reason, when I try to run my MonoGame project built as self-contained on .NET 6 and encounter usage of ZipFile class, it throw the following exception:

FileNotFoundException: Could not load file or assembly 'System.IO.Compression, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

The same code works perfectly fine in framework-dependent builds. I have tried disabling publishing as a single file and assembly trimming, it didn't fix the issue. Also tried installing System.IO.Compression from nuget, same results. What could be causing this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source