Skip to content

Depart BinaryFormatter for Exceptions serialization #8786

@JanKrivanek

Description

@JanKrivanek

Issue Description

Subitem of #6215

In order to transfer exceptions cross worker node boundaries the TranslateException Translator method uses TranslateDotNet member which relies upon BinaryFormatter.
The goal of this task is to rework TranslateException so that it doesn't rely upon BinaryFormatter.

This is a high priority item as current MSBuild insertion in SDK breaks due to this: #6215 (comment)

Steps to Reproduce

  1. Get the latest SDK build from https://github.com/dotnet/installer#installers-and-binaries
  2. Download and extract the lates zip for main build
  3. Point DOTNET_MSBUILD_SDK_RESOLVER_SDKS_DIR, DOTNET_ROOT, PATH to the extracted SDK (you can follow https://github.com/dotnet/sdk/blob/main/eng/dogfood.ps1#L38-L47)
  4. Verify proper dotnet redirection via dotnet --version command
  5. Use project with malformed property Condition - you can use this one BinaryFormatter Deprecation #6215 (comment)
  6. Make sure to force cross nodes communication ($env:MSBUILDNOINPROCNODE=1 and $env:MSBUILDDISABLENODEREUSE=1)
  7. Build the project

Expected Behavior

Build fails, but MSBuild doesn't crash

Actual Behavior

MSBuild crashes:

(...)
MSBUILD : error MSB4166: UNHANDLED EXCEPTIONS FROM PROCESS 25752:
MSBUILD : error MSB4166: =====================
MSBUILD : error MSB4166: 5/22/2023 11:10:07 AM
MSBUILD : error MSB4166: System.NotSupportedException: BinaryFormatter serialization and deserialization are disabled withi
n this application. See https://aka.ms/binaryformatter for more information.
MSBUILD : error MSB4166:    at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializatio
nStream, Object graph)
MSBUILD : error MSB4166:    at Microsoft.Build.Execution.BuildResult.Microsoft.Build.BackEnd.ITranslatable.Translate(ITrans
lator translator)
MSBUILD : error MSB4166:    at Microsoft.Build.BackEnd.NodeEndpointOutOfProcBase.RunReadLoop(Stream localReadPipe, Stream l
ocalWritePipe, ConcurrentQueue`1 localPacketQueue, AutoResetEvent localPacketAvailable, AutoResetEvent localTerminatePacket
Pump)
MSBUILD : error MSB4166: ===================
(...)

Metadata

Metadata

Assignees

Labels

Priority:1Work that is critical for the release, but we could probably ship withoutbugtriaged

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions