-
-
Notifications
You must be signed in to change notification settings - Fork 283
Fix compression bug by removing unnecessary Flush() call #1071
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
The Flush() call on DeflateStream doesn't guarantee complete compression and can cause embedded DLLs to fail until project rebuild. Removing it ensures proper compression on first build.
|
I have that problem too. |
|
Same problem with me. |
|
I think it's not the flush call, it might be the bool to leave the stream open. I will try to look into this with full context in mind (why is the stream being left open) as soon as I can. edit I noticed that the non-compression write does not flush. Will try to check this as soon as I have time. |
Thank you for offering to look into it. As of right now for a temp fix removing the flush call fixes it but you definitely know the project better than me. |
|
@GeertvanHorrik any news? |
|
@GeertvanHorrik now, on my newest build I'm getting the bad image exception but I still have the compression turned off so I'm not sure anymore. It only happens to 1 dll though which is another project that it's linking and NOT a nuget package. |
This comment was marked as abuse.
This comment was marked as abuse.
Are you sure you are embedding the right platform (x86, x64, arm64) and running in the right runtime? It would be best if we have a repro so we can actually write unit tests around this and make sure it never happens again (if Costura is to "blame" at all). |
They're all set to ANYCPU and to prefer 64bit. If you'd like, I can get the exact commit that shows where it's broken vs fixed in my own repo. Would that suffice? |
|
Please provide the commit (link if repo is OSS), then I will check it out. |
|
So far it seems to only be happening to me now (I promise it was happening to other people before as well.) https://github.com/Quasar-Continuation/Poopsar This is the repo.
I built the same exe twice and got 2 different sized outputs each time. I did and then rebuilt the project and that's what happened. The compression/bundling is failing on Pulsar.Common which is another project included all in the same .sln. I'm going to try disabling compression to see if it solves the issue. |
|
@GeertvanHorrik I tried without compression as well and I still get the same issue with occasional different file sizes. |
|
The github action however seems to build everything just fine and it's all useable. I tried clearing all nuget pacakges, all build stuff, reinstalled visual studio, reinstalled all my .net framework and core packages and the runtimes/sdk's themselves. |
|
I should also say, out of the 3 environments I tested, both windows 10 environments worked just fine, and others I've asked said it works just fine on windows 11 so I have no idea what could possibly be wrong at this point. |

The Flush() call on DeflateStream doesn't guarantee complete compression and can cause embedded DLLs to fail until project rebuild. Removing it ensures proper compression on first build.
Description of Change
Fix compression bug by removing unnecessary Flush() call
Issues Resolved
API Changes
None
None
Behavioral Changes
None
Testing Procedure
I couldn't even figure out how to run the tests because I didn't have the MSBuild SDK but the issue was so small that I don't believe tests are needed (or you can run them as well).
PR Checklist