Skip to content
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

[Breaking change]: Document MSBuild deprecation of custom derived BuildEventArgs #36403

Closed
3 tasks
JanKrivanek opened this issue Jul 26, 2023 · 1 comment
Closed
3 tasks
Assignees
Labels
breaking-change Indicates a .NET Core breaking change 🏁 Release: .NET 8 Work items for the .NET 8 release doc-idea Indicates issues that are suggestions for new topics [org][type][category] Pri1 High priority, do before Pri2 and Pri3 📌 seQUESTered Identifies that an issue has been imported into Quest.

Comments

@JanKrivanek
Copy link
Member

JanKrivanek commented Jul 26, 2023

Description

The document should be very visibly linked from https://learn.microsoft.com/en-us/dotnet/api/microsoft.build.framework.custombuildeventargs (or it should be made part of that document).

dotnet/msbuild#8917 introduces deprecation of custom derived build events of any subclass of BuildEventArgs by any build extensibility (mainly custom tasks).
From net8 - if any such event is used when building with NET8 version of msbuild (means from commandline) - a build error will be issued:

Usage of unsecure BinaryFormatter during serialization of custom event type 'MyCustomBuildEventArgs'. This will be deprecated soon. Please use Extended*EventArgs instead. More info: https://aka.ms/msbuild/eventargs

The behavior can be opted out via explicitly setting env. var MSBUILDCUSTOMBUILDEVENTWARNING to something else then 1.
The warning might be given a MSB code - then another way of suppressing would be usage of MSBuildWarningsAsMessages

When building on Full Framework version of MSBuild (Visual Studio case), then this behavior is not on by default. It'll be introduced in VS17.8 and will be explicit opt-in by setting MSBUILDCUSTOMBUILDEVENTWARNING to 1. When opted in, it will introduce a build warning (as opposed to build error in NET8+) with the same wording as above.

Version

.NET 8 RC 1

Previous behavior

It was allowed to derive from any subclass of BuildEventArgs and use those freely in custom Tasks and other build extensibility points

New behavior

A build error or a build warning will be issued

  Building your MSBuild extensibility Build leveraging the MSBuild extensibility with custom build events (regardless how that one was built) Previous scenario with MSBUILDCUSTOMBUILDEVENTWARNING=1 in environment Previous scenario with MSBUILDCUSTOMBUILDEVENTWARNING=0 in environment
.NET 8+ No change Build error,  Custom event dropped Build error,  Custom event dropped Build crashes  (unless EnableUnsafeBinaryFormatterSerialization explicitly enabled in MSBuild runtimeconfig)
.NET Framework 17.8+ No change No change Build warning,  Custom event transferred No change

Type of breaking change

  • Binary incompatible: Existing binaries may encounter a breaking change in behavior, such as failure to load or execute, and if so, require recompilation.
  • Source incompatible: When recompiled using the new SDK or component or to target the new runtime, existing source code may require source changes to compile successfully.
  • Behavioral change: Existing binaries may behave differently at run time.

Reason for change

Unsecure BinaryFormatter is going to be deprected (https://aka.ms/binaryformatter). From NET8 - usages of BinaryFormatter will lead to runtime errors (unless user explicitly opts-in with EnableUnsafeBinaryFormatterSerialization) - and custom derived build events rely on BinaryFormatter - so such a build would fail anyways. Current build error/warning gives more grace information.

The runtime errors do not apply to Full Framework yet - hence the build warning is opt-in for Full Framework. However this will change very soon (current deadline for BinaryFormatter removal is 2023-12-31 - https://liquid.microsoft.com/Web/Object/Read/MS.Security/Requirements/Microsoft.Security.SystemsADM.10010#Zguide), so opting-in and refactoring is strongly recommended.

Recommended action

Proper approach is to move to any of the offered alternative build-in events for extensibility (code links will be provided once PR is merged. Those types should be probably documented with generated documentations similarly as CustomBuildEventArgs as part of this documenting effort):

  • ExtendedCustomBuildEventArgs
  • ExtendedBuildErrorEventArgs
  • ExtendedBuildMessageEventArgs
  • ExtendedBuildWarningEventArgs

Alternatively users can temporarily disable the check by explicitly setting env. var MSBUILDCUSTOMBUILDEVENTWARNING to something else then 1.
The warning might be given a MSB code - then another way of suppressing would be usage of MSBuildWarningsAsMessages

Feature area

Other (please put exact area in description textbox)

Affected APIs

https://learn.microsoft.com/en-us/dotnet/api/microsoft.build.framework.custombuildeventargs


Associated WorkItem - 156744

@JanKrivanek JanKrivanek added doc-idea Indicates issues that are suggestions for new topics [org][type][category] breaking-change Indicates a .NET Core breaking change Pri1 High priority, do before Pri2 and Pri3 labels Jul 26, 2023
@dotnet-bot dotnet-bot added the ⌚ Not Triaged Not triaged label Jul 26, 2023
@gewarren gewarren removed the ⌚ Not Triaged Not triaged label Jul 26, 2023
@gewarren gewarren added the 🏁 Release: .NET 8 Work items for the .NET 8 release label Jul 31, 2023
@gewarren gewarren moved this from 🔖 Ready to 🏗 In progress in dotnet/docs September 2023 sprint Sep 5, 2023
@gewarren
Copy link
Contributor

gewarren commented Sep 5, 2023

Tagging @ghogen to update the API docs as necessary.

@gewarren gewarren added the 🗺️ reQUEST Triggers an issue to be imported into Quest. label Sep 5, 2023
@gewarren gewarren moved this from 🏗 In progress to 👀 In review in dotnet/docs September 2023 sprint Sep 5, 2023
@gewarren gewarren moved this from 👀 In review to 🏗 In progress in dotnet/docs September 2023 sprint Sep 5, 2023
@github-actions github-actions bot added 📌 seQUESTered Identifies that an issue has been imported into Quest. and removed 🗺️ reQUEST Triggers an issue to be imported into Quest. labels Sep 6, 2023
@gewarren gewarren moved this from 🏗 In progress to ✅ Done in dotnet/docs September 2023 sprint Sep 13, 2023
@gewarren gewarren moved this from 🆕 New to ✅ Done in .NET 8.0 work items Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change Indicates a .NET Core breaking change 🏁 Release: .NET 8 Work items for the .NET 8 release doc-idea Indicates issues that are suggestions for new topics [org][type][category] Pri1 High priority, do before Pri2 and Pri3 📌 seQUESTered Identifies that an issue has been imported into Quest.
Projects
No open projects
Status: Done
Status: Done
Development

No branches or pull requests

4 participants