Why does EnableCompressionInSingleFile require Self-Contained=true? #61424
-
I was excited to see compression support in .NET 6. However, I see that it is only an option if Self-Contained is true. Why is that? Why can't we have compression with framework dependant assemblies? Also, I can't seem to find the option in the UI in VS 2022 17 or VS 2022 17.1. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
It's a bit technically challenging to do so. With self-contained, the entire runtime + libraries are part of the executable. Among other things this includes the native parts of the compression algorithms used in the libraries. The host in this case can directly call into the compression algorithm since it's included anyway. If we were to enable this for framework dependent applications, either the host would have to carry the decompression code in it or it would have to pull it from the framework. The first option is problematic - currently we have only one host for FDD apps, so we would either have to make it larger for everybody, or add another one (more complexity). The second option is also relatively tricky due to the other in which the code is executed (we may need to decompress before we know which runtime we're going to use). Both are solvable, but we simply didn't think it's worth the effort. At least yet. Framework dependent applications tend to be much smaller and thus the need for compression is probably less. That said, I would be interested in your scenario, so that we can prioritize this work in the future. |
Beta Was this translation helpful? Give feedback.
-
@vitek-karas, Thank you for the response, it's much appreciated. I wouldn't say its necessarily a requirement for our scenario. In .NETFramework I was used to either using Fody/Costrua or an obfuscation engine to compress resources (images/libraries/etc), and the resulting assembly and its dependencies so that I have a single deployable app that is packed as much as it can be. Some of our apps hover around 50mb in size due to 3rd party library bloat. Much of it is XML declarations that could be compressed significantly. Would the Trim Unused Code feature allow the optional bundling of the decompresion code in the host? |
Beta Was this translation helpful? Give feedback.
It's a bit technically challenging to do so. With self-contained, the entire runtime + libraries are part of the executable. Among other things this includes the native parts of the compression algorithms used in the libraries. The host in this case can directly call into the compression algorithm since it's included anyway.
If we were to enable this for framework dependent applications, either the host would have to carry the decompression code in it or it would have to pull it from the framework. The first option is problematic - currently we have only one host for FDD apps, so we would either have to make it larger for everybody, or add another one (more complexity). The second option …