Skip to content

Commit

Permalink
Allow MSBuild to use BinaryFormatter (#33227)
Browse files Browse the repository at this point in the history
With EnableUnsafeBinaryFormatterSerialization=false, MSBuild can crash
instead of passing along an error, dotnet/msbuild#8786. Temporarily
opt back into the old behavior while fixing this in MSBuild.
  • Loading branch information
rainersigwald authored Jun 14, 2023
1 parent 5e6eaeb commit 5f90e87
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Layout/redist/targets/GenerateLayout.targets
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,9 @@
<PropertyGroup>
<ReplacementPattern>"version": ".*"</ReplacementPattern>
<ReplacementString>"version": "$(MicrosoftNETCoreAppRuntimePackageVersion)"</ReplacementString>

<DisabledBinaryFormatterPattern>"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false</DisabledBinaryFormatterPattern>
<EnableBinaryFormatterString>"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": true</EnableBinaryFormatterString>
</PropertyGroup>
<ItemGroup>
<!-- Exclude F# from retargeting: https://github.com/dotnet/toolset/issues/2866 -->
Expand All @@ -453,6 +456,14 @@
ReplacementPatterns="$(ReplacementPattern)"
ReplacementStrings="$(ReplacementString)" />

<!-- Work around https://github.com/dotnet/msbuild/issues/6215 by opting back into net7 behavior -->
<ReplaceFileContents
InputFiles="@(ToolRuntimeConfigPath)"
DestinationFiles="@(ToolRuntimeConfigPath)"
ReplacementPatterns="$(DisabledBinaryFormatterPattern)"
ReplacementStrings="$(EnableBinaryFormatterString)"
Condition=" '%(ToolRuntimeConfigPath.FileName)' == 'MSBuild.runtimeconfig'" />

<Move
SourceFiles="@(MSBuild15Items)"
DestinationFiles="@(MSBuild15Items -> '$(OutputPath)/Current/%(RecursiveDir)%(Filename)%(Extension)')" />
Expand Down

0 comments on commit 5f90e87

Please sign in to comment.