dotnet / dotnet/msbuild

Deprecate CodeTaskFactory in favor of RoslynCodeTaskFactory

Open
#12,349 1 comment 1 reaction 1 assignee Assigned to @Copilot View on GitHub
Feature Request
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 13h
Merged PRs (30d)
133

Description

### Summary

Deprecate `CodeTaskFactory` in favor of the more modern and widely supported `RoslynCodeTaskFactory` by introducing a changewave-driven behavior. This would ensure existing XML-based usages of `CodeTaskFactory` are transparently redirected to `RoslynCodeTaskFactory` when the changewave is enabled, with a clear log message informing users of the transition.

### Background and Motivation

Currently, MSBuild supports both `CodeTaskFactory` (for .NET Framework only) and `RoslynCodeTaskFactory` (for both .NET Framework and .NET). Having two functionally identical task factories increases maintenance complexity and can confuse users. The goal is to deprecate `CodeTaskFactory` and encourage migration to `RoslynCodeTaskFactory`, but preserve compatibility and minimize disruption for existing builds.

### Proposed Feature

Implement a changewave-driven tweak in the `RegisterTasksFromUsingTaskElement` method. When the changewave is enabled, any invocation of `CodeTaskFactory` via XML should be treated as if it was `RoslynCodeTaskFactory` instead. Additionally, MSBuild should log a message indicating that `CodeTaskFactory` has been transparently mapped to `RoslynCodeTaskFactory` due to deprecation. This provides a gentle transition path and allows for opt-out via the existing change wave machinery.

- Update `RegisterTasksFromUsingTaskElement` to check for the changewave and substitute `CodeTaskFactory` with `RoslynCodeTaskFactory`.
- Ensure the log message is informative and only appears when the substitution occurs.
- Retain legacy behavior for builds not opting into the change wave.
- Document this transition in both internal and user-facing docs, referencing the change wave.
- Investigate if there are any edge cases or downstream impacts of this substitution, especially in behavior or compatibility.
- Related: [documentation/wiki/ChangeWaves-Dev.md](https://github.com/dotnet/msbuild/blob/main/documentation/wiki/ChangeWaves-Dev.md)

### Alternative Designs

_No response_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.