Make BinFmt changewave dependent on BinFmt runtime enablement #9262
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #9258
Summary
Opting out of 17.8 features (via changewaves env variable) while
EnableUnsafeBinaryFormatterSerialization
is not allowed by the runtime can lead to MSBuild crashing ungracefully.This is because BinaryFormatter serialization usage in core now leads to runtime failures (as of 8.0) unless explicitly opted-in by user. So MSBuild moved to alternative (secure) serialization. MSBuild normally allows users to opt out of the last batch of changes - with changewaves. In this specific case it can mean shooting self into foot without realizing.
Resolution: Ignoring the opt-out of the new secure serialization unless the BinaryFormatter is explicitly allowed by user in runtime (by editing
MSBuild.runtimeconfig.json
in the SDK).Customer Impact
If users have encountered a problem in the latest MSBuild and are working around it by enabling a changewave (for instance, working around the potential deployment blocker #9250), some categories of build failure manifest as an MSBuild crash rather than a failed build with a descriptive error.
Changes Made
Allow flipping to the legacy serialization only if the BinFmt is allowed in runtime (or we are running on .NET Framework).
For exception serialization - it actually should be just internal technical detail without user behavior change - so not allowing to change this with changewave
Regression?
Yes, introduced in #8917.
Testing
Manual (mentioned in the item)
Risk
Low (adding boolean check populated from AppContext switch)