Skip to content

Parse and retain task and target operation phases - #15768

Draft
JohnSchmeichel wants to merge 1 commit into
dotnet:mainfrom
JohnSchmeichel:johsch/parse-task-target-phases
Draft

JohnSchmeichel wants to merge 1 commit into
dotnet:mainfrom
JohnSchmeichel:johsch/parse-task-target-phases

Conversation

@JohnSchmeichel

@JohnSchmeichel JohnSchmeichel commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Related issue(s):

Relates to #15656.

Context

Establish parser and object-model support for task, target property, and target item phase declarations without implementing phase resolution or execution. This upstream PR carries the changes staged in gim-home/msbuild-precompute#169.

Changes Made

  • Accept DefaultPhase on UsingTask and retain its unevaluated value in task registrations and project-state translation.
  • Retain MSBuildPhase expressions and locations on construction elements and task, target property, and target item instances, including translation.
  • Reserve MSBuildPhase on task invocations and item attributes behind Change Wave 18.14, including reserved-attribute casing rules; retain legacy parameter and metadata behavior when opted out.
  • Accept MSBuildPhase on properties inside targets independently of the wave.
  • Add schema support, phase documentation, and focused regression tests.

Compatibility

MSBUILDDISABLEFEATURESFROMVERSION=18.14 restores MSBuildPhase as an ordinary task parameter or item attribute metadata, including case variants. With the wave enabled, project-level item attributes are reserved and ignored during evaluation, and item definitions reject the attribute; child-element metadata remains available. DefaultPhase and target property attributes are accepted independently of the wave. Project-level properties reject MSBuildPhase.

Phase expressions are not expanded or validated by this change. Ordinary task, property, and item execution is unchanged apart from the wave-gated reservation. New construction/instance APIs and internal project-state translation fields retain the declarations; task registrations do not retain the DefaultPhase source location. Older MSBuild versions do not recognize the new UsingTask attribute, and mixed-version translation compatibility has not been validated. The shared schema property types also permit MSBuildPhase on project-level properties although the runtime parser rejects it.

Testing

Focused upstream-main checks on macOS, run serially, passed:

  • dotnet test src/Build.UnitTests/Microsoft.Build.Engine.UnitTests.csproj --no-restore -f net11.0 -v quiet -p:CreateBootstrap=false -- --filter-method '*Phase*' — passed, 10/10.
  • dotnet test src/Build.OM.UnitTests/Microsoft.Build.Engine.OM.UnitTests.csproj --no-restore -f net11.0 -v quiet -p:CreateBootstrap=false -- --filter-method '*Phase*' — passed, 27/27.
  • dotnet test src/Build.OM.UnitTests/Microsoft.Build.Engine.OM.UnitTests.csproj --no-restore -f net11.0 -v quiet -p:CreateBootstrap=false -- --filter-class '*ProjectItemElement_Tests' — passed, 100/100.
  • dotnet test src/Build.OM.UnitTests/Microsoft.Build.Engine.OM.UnitTests.csproj --no-restore -f net11.0 -v quiet -p:CreateBootstrap=false -- --filter-class '*ProjectItemDefinitionElement_Tests' — passed, 14/14.
  • dotnet test src/MSBuild.UnitTests/Microsoft.Build.CommandLine.UnitTests.csproj --no-restore -f net11.0 -v quiet -p:CreateBootstrap=false -- --filter-class '*ProjectSchema_Tests' — passed, 1/1.

On the release staging branch, ./eng/build.sh --build -v quiet passed with zero warnings and errors; the sample build and CLI help also succeeded. The full test suite, Windows/.NET Framework runs, and mixed-version hosts were not tested.

Dependencies and Follow-up

No new dependencies. Phase resolution and validation (Precompute or Compute), graph construction, and precompute/compute execution remain follow-up work. Target property and item phases default to Precompute when absent; tasks require a phase from their invocation or registration.

Relates to dotnet#15656

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).
Some pipeline(s) encountered errors during trigger evaluation.

@JohnSchmeichel JohnSchmeichel linked an issue Dec 4, 2026 that may be closed by this pull request
@JohnSchmeichel JohnSchmeichel linked an issue Dec 4, 2026 that may be closed by this pull request

This branch has not been deployed

No deployments
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.

Parser changes & back-compat (MSBuildPhase)

1 participant