-
Notifications
You must be signed in to change notification settings - Fork 366
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
Migrate away from BinaryFormatter
?
#818
Comments
It's more a limitation than a bug, but it's not exactly a new feature either, which is why I created a bug. |
I used .NET 6.0 and I have the following properties in my csproj, which might influence the situation.
|
BinaryFormatter
BinaryFormatter
?
Just a heads-up: I crossed this before too and plan to replace with JSON serialization. |
|
@tyb-dev have you found a workaround ? I have the same problem with a selfcontained |
Not without changing Nuke itself. |
I managed to workaround it by disabling "PublishTrimmed". It's twice as big as my ordinary binary but that should do it for now until the change is made. |
In .NET 8 preview docker Restore step throws.
|
@voroninp you can use @matkoch just a head's up: starting with .NET 9, binary serialization will be removed (according to the current roadmap). Is this something where a contribution would help / be feasiable? |
Please take a look: #1247 |
Workaround taken from #1282 which has been closed as a duplicate of this bug: Add this to your Nuke project's <PropertyGroup>
.. other existing properties ...
<EnableUnsafeBinaryFormatterSerialization>true</EnableUnsafeBinaryFormatterSerialization>
</PropertyGroup> Note: Update Oct2024: this workaround only applies to dotnet 8. For dotnet 9, BinaryFormatter has been completely removed and this has no effect. Others have posted updated workarounds below |
Would something like this solve it?
|
When will this be fixed? |
The EnableUnsafeBinaryFormatterSerialization workaround is not working on at least the latest .NET 8 SDK, so a fix would be really appreciated. |
With dotnet 9 Preview 6, BinaryFormatter is gone. 67.29 14:30:09 [ERR] Target Restore has thrown an exception |
@matkoch As a temporary solution, if migration is difficult to .NET 9, you can use the package System.Runtime.Serialization.Formatters (BinaryFormatter has been moved here) |
Thanks @nsentinel, that seems to work |
BinaryFormatter removal from .NET 9 is complete: dotnet/announcements#317 |
+1 cannot use nuke in net9 |
@jjaskulowski-configit As a temporary workaround, you can set .NET 8 target for nuke (_build project), and .NET 9 for everything else. nuke will build such solution fine |
Here is Microsoft's https://learn.microsoft.com/en-us/dotnet/standard/serialization/binaryformatter-migration-guide/compatibility-package
I added The first time I attempted this, I just had Note: If you are reading this in the future when .NET 9 is generally available, please reference the 9.0 packages and not RC2.
I found this also worked for me. The downside is that it requires both .NET 8 and 9 SDK's to be installed in CI environments. I will proceed with the |
Another possible solution to avoid BinaryFormatter is to use Typeless mode in MessagePack - https://github.com/MessagePack-CSharp/MessagePack-CSharp?tab=readme-ov-file#typeless. If the option of saving to JSON is too inconvenient for some reason |
@matkoch why would you add it to the milestone and close it? I can't find an "open" task or PR for it, and the binaryformatter is still there |
I upgraded package to
and add package
to the nuke project. Off-topic with some criticism: this issue was created about 3 years ago, and it was repeatedly warned that not only should it be migrated away from |
@ScarletKuro you're concerned about an issue that
I'm still following an issue about failing SWA deployments under Microsoft umbrella. It's 2,5 years old and has about 100 "me too" comments without any Microsoft response. The only workaround is recreating the resource. How concerned should I be and where can I escalate this?! :)
FYI, there are plenty of folks more closely connected to me/the project, and I have yet to encounter any serious complaints. Thanks for your understanding. PS: I pinned the issue as per your request. |
Usage Information
6.0.0-beta0001
Relevant Code / Invocations
Expected Behavior
No exception
What actually happened?
Exception while using Docker Nuke wrapper
Stacktrace / Log
Anything else we should know?
BinaryFormatter
s are prohibited under certain circumstances. Although this usage withinSettingsEntityExtensions
arguably has no security implications, theBinaryFormatter
might not be available generally for the entire app, which restricts usage of Nuke.https://docs.microsoft.com/en-us/dotnet/core/compatibility/core-libraries/5.0/binaryformatter-serialization-obsolete
The text was updated successfully, but these errors were encountered: