Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 14, 2025

This PR implements a breaking change to restrict custom task factory implementations that are not internal to MSBuild, gated behind change wave 17.16. Custom task factories are incompatible with upcoming multithreaded MSBuild improvements and have minimal known usage.

Changes Made

1. Deprecation Documentation

  • Added clear deprecation comments to ITaskFactory and ITaskFactory2 interfaces explaining the restriction and its rationale
  • Documents that only built-in MSBuild task factories should be used going forward

2. Restriction Logic

  • Implemented IsBuiltInTaskFactory() method in TaskRegistry.cs that validates task factory names against allowed built-in factories:
    • AssemblyTaskFactory (default)
    • TaskHostFactory (out-of-process execution)
    • CodeTaskFactory (inline code tasks)
    • XamlTaskFactory (XAML-based tasks)
    • RoslynCodeTaskFactory (Roslyn-compiled inline tasks)
  • Added restriction check that throws MSB4279 error when custom task factories are used and change wave 17.16 is enabled

3. Change Wave Integration

  • Added change wave 17.16 to ChangeWaves.cs
  • Restriction is opt-out via MSBUILDDISABLEFEATURESFROMVERSION=17.16 environment variable
  • Allows users to temporarily disable the restriction if their builds depend on custom task factories

4. Error Handling

  • Added new error message MSB4279 with clear guidance:
    • Identifies which task factory is not supported
    • Lists allowed built-in factories
    • Explains how to opt out temporarily

5. Comprehensive Testing

  • Added tests verifying custom factories are blocked when change wave is enabled
  • Added tests verifying custom factories are allowed when change wave is disabled via environment variable
  • Added tests verifying built-in factories continue to work regardless of change wave setting

6. Documentation Updates

  • Updated ChangeWaves.md to document the new restriction and its purpose

Manual Verification

Testing confirms the implementation works correctly:

<!-- This now fails with MSB4279 -->
<UsingTask TaskName="CustomTask" 
           AssemblyFile="dummy.dll"
           TaskFactory="MyCustomTaskFactory" />
# Opt-out works correctly
MSBUILDDISABLEFEATURESFROMVERSION=17.16 msbuild project.proj

# Built-in factories continue to work
<UsingTask TaskFactory="AssemblyTaskFactory" ... />  <!-- ✓ Works -->

Migration Guidance

Users affected by this change should:

  1. Remove custom task factory implementations
  2. Use built-in task factories or standard task implementations
  3. Temporarily set MSBUILDDISABLEFEATURESFROMVERSION=17.16 if immediate migration is not possible

This change improves MSBuild's compatibility with future multithreaded improvements while maintaining backward compatibility through the change wave opt-out mechanism.

Fixes #12347.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copy link
Contributor Author

Copilot AI commented Aug 14, 2025

@rainersigwald 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

@Copilot Copilot AI changed the title [WIP] Deprecate and restrict non-MSBuild TaskFactory implementations Deprecate and restrict non-MSBuild TaskFactory implementations Aug 14, 2025
Copilot finished work on behalf of rainersigwald August 14, 2025 20:54
@Copilot Copilot AI requested a review from rainersigwald August 14, 2025 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deprecate and restrict non-MSBuild TaskFactory implementations
2 participants