Skip to content

Migrate existing tasks to typed task parameters - #6

Draft
OvesN wants to merge 3 commits into
mainfrom
dev/veronikao/typed-task-parameter-examples
Draft

Migrate existing tasks to typed task parameters#6
OvesN wants to merge 3 commits into
mainfrom
dev/veronikao/typed-task-parameter-examples

Conversation

@OvesN

@OvesN OvesN commented Jul 23, 2026

Copy link
Copy Markdown
Owner

Fixes #

Context

The typed task-parameter PR chain (dotnet#13971-dotnet#13974) added AbsolutePath, FileInfo, DirectoryInfo, ITaskItem<T>, and migration analyzers. This draft uses the analyzer as a real task author and migrates three existing in-box tasks rather than adding custom examples.

Changes Made

  • Migrate VerifyFileHash.File from string to AbsolutePath.
  • Migrate ZipDirectory.SourceDirectory and DestinationFile to ITaskItem<DirectoryInfo> and ITaskItem<FileInfo>.
  • Migrate GetFileHash.Files to ITaskItem<AbsolutePath>[].
  • Preserve relative path text in live task-parameter logging, node forwarding, and binlog serialization.
  • Normalize invalid typed-item paths to MSB4030 instead of allowing an unhandled exception.
  • Add direct factories for the three path-like TaskItem<T> types so these migrations do not require runtime code generation under Native AOT.
  • Add unit and project-level coverage for relative binding, metadata preservation, malformed paths, logging, and serialization.
  • Remove the custom TypedTaskParameters sample from the previous draft.

Testing

  • Full Debug build with .NET MSBuild
  • VerifyFileHash_Tests, ZipDirectory_Tests, and GetFileHash_Tests on net11.0 and net472
  • TaskItemOfTTests on net11.0 and net472
  • TaskExecutionHost_Tests on net11.0 and net472
  • Task-parameter forwarding/binlog serialization round-trip on net11.0 and net472
  • Real MSBuild project using relative paths and GetFileHash metadata on net11.0 and net472
  • Analyzer rerun with MSBuildTask0006-0008 promoted to warnings; the migrated diagnostics are gone

Notes

Analyzer/user experience:

  • Normal command-line builds do not show MSBuildTask0006-0008 because they are Info diagnostics. Temporarily promoting them surfaced the migration candidates.
  • The analyzer recommended exactly these types:
    • VerifyFileHash.FileAbsolutePath
    • ZipDirectory.SourceDirectoryITaskItem<DirectoryInfo>
    • ZipDirectory.DestinationFileITaskItem<FileInfo>
    • GetFileHash.FilesITaskItem<AbsolutePath>[]
  • The shipped code fix applied only to the direct TaskEnvironment.GetAbsolutePath(File) case in VerifyFileHash; the typed-item migrations required manual edits.
  • Real end-to-end use exposed missing infrastructure for invalid paths, AOT path factories, task-parameter logging, and binlog serialization; those are fixed in this draft.

Intentional draft limitations:

  • These public task-property type changes are source- and binary-breaking for direct .NET callers. Release package validation reports CP0002; no suppression is added.
  • Explicitly forcing these attributed tasks through the legacy TaskHostFactory remains unsupported because that transport erases typed parameter types. Normal routing executes [MSBuildMultiThreadableTask] tasks in-process.

OvesN and others added 3 commits July 23, 2026 18:26
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace the custom sample with analyzer-guided migrations for VerifyFileHash, ZipDirectory, and GetFileHash. Harden typed path binding and logging based on end-to-end validation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@OvesN OvesN changed the title Add typed task parameter samples Migrate existing tasks to typed task parameters Aug 11, 2026
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.

1 participant