diff --git a/docs/core/compatibility/7.0.md b/docs/core/compatibility/7.0.md index 90713ef94ba11..cbdee353e12a0 100644 --- a/docs/core/compatibility/7.0.md +++ b/docs/core/compatibility/7.0.md @@ -47,11 +47,12 @@ If you're migrating an app to .NET 7, the breaking changes listed here might aff | [AllowRenegotiation default is false](networking/7.0/allowrenegotiation-default.md) | ❌ | ❌ | Preview 3 | | [Custom ping payloads on Linux](networking/7.0/ping-custom-payload-linux.md) | ❌ | ✔️ | Preview 2 | -## SDK +## SDK and MSBuild | Title | Binary compatible | Source compatible | Introduced | | - | :-: | :-: | - | | [Version requirements for .NET 7 SDK](sdk/7.0/vs-msbuild-version.md) | ✔️ | ✔️ | 7.0.100 | +| [MSBuild serialization of custom types in .NET 7](sdk/7.0/custom-serialization.md) | ❌ | ❌ | 7.0.100 | ## Serialization diff --git a/docs/core/compatibility/sdk/7.0/custom-serialization.md b/docs/core/compatibility/sdk/7.0/custom-serialization.md new file mode 100644 index 0000000000000..52390cc8c62c3 --- /dev/null +++ b/docs/core/compatibility/sdk/7.0/custom-serialization.md @@ -0,0 +1,32 @@ +--- +title: "Breaking change: Serialization of custom types in .NET 7" +description: Learn about a breaking change in MSBuild for .NET 7 where serialization using BinaryFormatter of certain user-defined types is removed. +author: baronfel +ms.date: 05/06/2022 +--- + +# BinaryFormatter serialization of custom BuildEventArgs and ITaskItems removed for .NET 7 + +MSBuild in .NET 7 doesn't support serialization of custom `BuildEventArgs`-derived and `ITaskItem`-derived types via the `BinaryFormatter` serializer. + +## Version introduced + +MSBuild 17.4 (.NET SDK 7.0.100) + +## Old behavior + +MSBuild used BinaryFormatter to preserve custom types that derived from BuildEventArgs and ITaskItem across certain boundaries, most notably when running in a multi-process environment. + +## New behavior + +MSBuild will no longer support this mechanism, so code that used custom types derived from BuildEventArgs and ITaskItem may fail. + +## Reason for change + +BinaryFormatter was [made obsolete in .NET 5](https://github.com/dotnet/designs/blob/main/accepted/2020/better-obsoletion/binaryformatter-obsoletion.md). Per this plan, all first-party code in the dotnet GitHub organization must migrate away from its use by .NET 7. This change impacts user-exposed functionality of MSBuild. + +## Recommended action + +* Engage with the MSBuild team on [this GitHub discussion](https://github.com/dotnet/msbuild/discussions/7582) about your specific use cases and how you can migrate away from the `TranslateDotNet` mechanism. + +* Avoid returning custom derived types from tasks or when logging. diff --git a/docs/core/compatibility/toc.yml b/docs/core/compatibility/toc.yml index d47aecf4d2088..c86c065a527d0 100644 --- a/docs/core/compatibility/toc.yml +++ b/docs/core/compatibility/toc.yml @@ -61,10 +61,12 @@ items: href: networking/7.0/allowrenegotiation-default.md - name: Custom ping payloads on Linux href: networking/7.0/ping-custom-payload-linux.md - - name: SDK + - name: SDK and MSBuild items: - name: Version requirements for .NET 7 SDK href: sdk/7.0/vs-msbuild-version.md + - name: Serialization of custom types in .NET 7 + href: sdk/7.0/custom-serialization.md - name: Serialization items: - name: Deserialize Version type with leading or trailing whitespace @@ -965,6 +967,8 @@ items: items: - name: Version requirements for .NET 7 SDK href: sdk/7.0/vs-msbuild-version.md + - name: Serialization of custom types in .NET 7 + href: sdk/7.0/custom-serialization.md - name: .NET 6 items: - name: -p option for `dotnet run` is deprecated