Skip to content

Remove the custom BuildTask base class - #17427

Merged
ViktorHofer merged 4 commits into
dotnet:mainfrom
ViktorHofer:buildtask-removal
Aug 28, 2026
Merged

ViktorHofer merged 4 commits into
dotnet:mainfrom
ViktorHofer:buildtask-removal

Conversation

@ViktorHofer

@ViktorHofer ViktorHofer commented Aug 27, 2026 •

Copy link
Copy Markdown
Member

BuildTask (src/Common/Internal/BuildTask.cs) reimplemented what Microsoft.Build.Utilities.Task already provides, and wrapped TaskLoggingHelper in a parallel ILog/LogImportance abstraction that only forwarded calls while shadowing the standard MSBuild logging API. It was source-included into nine task projects.

  • Deleted src/Common/Internal/BuildTask.cs (BuildTask, Log, ILog, LogImportance) and its <Compile Include> entries from the nine consuming projects.
  • Rebased the 54 derived tasks on Microsoft.Build.Utilities.Task; replaced ILog with TaskLoggingHelper and LogImportance with MessageImportance.
  • Inlined the three remaining using BuildTask = Microsoft.Build.Utilities.Task; aliases so the BuildTask name is gone entirely.

These types are not part of any package's public surface — the task assemblies ship outside ref/lib, so nothing binds against them.

Shrinks the diff for #17378.

…ilities.Task

BuildTask (src/Common/Internal/BuildTask.cs) reimplemented what
Microsoft.Build.Utilities.Task already provides, and wrapped
TaskLoggingHelper in a parallel ILog/LogImportance abstraction that only
forwarded calls and shadowed the standard MSBuild logging API. It was
source-included into nine task projects.

- Delete src/Common/Internal/BuildTask.cs (BuildTask, Log, ILog, LogImportance)
  and its <Compile Include> entries from the nine consuming projects.
- Rebase the 54 derived tasks on Microsoft.Build.Utilities.Task, and replace
  ILog with TaskLoggingHelper and LogImportance with MessageImportance.
- Inline the three remaining `using BuildTask = Microsoft.Build.Utilities.Task;`
  aliases so the BuildTask name is gone entirely.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: be19d794-fe4f-43fe-9e6e-f6e6b13ec6e7
Copilot AI lite review requested due to automatic review settings August 27, 2026 15:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes the repo’s custom BuildTask base class and its ILog/LogImportance logging abstraction, rebasing the affected MSBuild tasks onto Microsoft.Build.Utilities.Task and the standard TaskLoggingHelper/MessageImportance APIs. This simplifies the task implementation surface and reduces future friction for follow-on work like #17378 (multi-threadable task annotation).

Changes:

  • Deleted src/Common/Internal/BuildTask.cs and removed all source-include <Compile Include="..\Common\Internal\BuildTask.cs" .../> references from consuming projects.
  • Migrated derived tasks to Microsoft.Build.Utilities.Task and updated logging calls from ILog/LogImportance to TaskLoggingHelper/MessageImportance.
  • Updated unit test helpers that depended on the old logging abstraction.
Show a summary per file
File Description
src/Microsoft.DotNet.SignTool/src/SignToolTask.cs Removes BuildTask alias; task now derives from Microsoft.Build.Utilities.Task.
src/Microsoft.DotNet.SignCheckTask/SignCheckTask.cs Removes BuildTask alias; task now derives from Microsoft.Build.Utilities.Task.
src/Microsoft.DotNet.SharedFramework.Sdk/src/ValidateFileVersions.cs Switches from BuildTask to MSBuild Task base.
src/Microsoft.DotNet.SharedFramework.Sdk/src/GenerateSharedFrameworkDepsFile.cs Switches from BuildTask to MSBuild Task base.
src/Microsoft.DotNet.SharedFramework.Sdk/src/GeneratePlatformManifestEntriesFromTemplate.cs Switches from BuildTask to MSBuild Task base.
src/Microsoft.DotNet.SharedFramework.Sdk/src/GeneratePlatformManifestEntriesFromFileList.cs Switches from BuildTask to MSBuild Task base.
src/Microsoft.DotNet.SharedFramework.Sdk/src/CreateFrameworkListFile.cs Switches from BuildTask to MSBuild Task base.
src/Microsoft.DotNet.SharedFramework.Sdk/Microsoft.DotNet.SharedFramework.Sdk.csproj Removes source include of Common/Internal/BuildTask.cs.
src/Microsoft.DotNet.PackageTesting/VerifyTypes.cs Switches from BuildTask to MSBuild Task base.
src/Microsoft.DotNet.PackageTesting/VerifyClosure.cs Switches from BuildTask to MSBuild Task base; updates logging importance enum.
src/Microsoft.DotNet.PackageTesting/Microsoft.DotNet.PackageTesting.csproj Removes source include of Common/Internal/BuildTask.cs.
src/Microsoft.DotNet.PackageTesting/GetCompatiblePackageTargetFrameworks.cs Switches from BuildTask to MSBuild Task base.
src/Microsoft.DotNet.GenFacades/SourceGenerator.cs Replaces ILog with TaskLoggingHelper.
src/Microsoft.DotNet.GenFacades/RoslynBuildTask.cs Switches from BuildTask to MSBuild Task base.
src/Microsoft.DotNet.GenFacades/Microsoft.DotNet.GenFacades.csproj Removes source include of Common/Internal/BuildTask.cs.
src/Microsoft.DotNet.GenFacades/GenPartialFacadeSourceGenerator.cs Replaces ILog with TaskLoggingHelper in helper APIs.
src/Microsoft.DotNet.GenFacades/ClearAssemblyReferenceVersions.cs Switches from BuildTask to MSBuild Task base.
src/Microsoft.DotNet.GenAPI/Microsoft.DotNet.GenAPI.csproj Removes source include of Common/Internal/BuildTask.cs.
src/Microsoft.DotNet.GenAPI/GenAPITask.cs Switches from BuildTask to MSBuild Task base; replaces ILog and importance enum usages.
src/Microsoft.DotNet.CMake.Sdk/src/GetCMakeArtifactsFromFileApi.cs Switches from BuildTask to MSBuild Task base; updates logging importance enum.
src/Microsoft.DotNet.CMake.Sdk/src/CreateCMakeFileApiQuery.cs Switches from BuildTask to MSBuild Task base; updates logging importance enum.
src/Microsoft.DotNet.CMake.Sdk/Microsoft.DotNet.CMake.Sdk.csproj Removes source include of Common/Internal/BuildTask.cs.
src/Microsoft.DotNet.Build.Tasks.Workloads/src/Microsoft.DotNet.Build.Tasks.Workloads.csproj Removes stale/commented source include of BuildTask.cs.
src/Microsoft.DotNet.Build.Tasks.TargetFramework/src/Microsoft.DotNet.Build.Tasks.TargetFramework.csproj Removes source include of Common/Internal/BuildTask.cs.
src/Microsoft.DotNet.Build.Tasks.TargetFramework/src/ChooseBestTargetFrameworksTask.cs Switches from BuildTask to MSBuild Task base.
src/Microsoft.DotNet.Build.Tasks.TargetFramework/src/ChooseBestP2PTargetFrameworkTask.cs Switches from BuildTask to MSBuild Task base; replaces Log wrapper parameter with TaskLoggingHelper.
src/Microsoft.DotNet.Build.Tasks.Packaging/tests/TestBuildEngine.cs Updates test build engine to use new test Log helper and MessageImportance.
src/Microsoft.DotNet.Build.Tasks.Packaging/tests/Log.cs Replaces ILog test abstraction with a concrete Log helper using MessageImportance.
src/Microsoft.DotNet.Build.Tasks.Packaging/src/ValidationTask.cs Switches from BuildTask to MSBuild Task base.
src/Microsoft.DotNet.Build.Tasks.Packaging/src/ValidateHarvestVersionIsLatestForRelease.cs Switches from BuildTask to MSBuild Task base; updates logging importance enum.
src/Microsoft.DotNet.Build.Tasks.Packaging/src/ValidateFrameworkPackage.cs Updates logging importance enum usage.
src/Microsoft.DotNet.Build.Tasks.Packaging/src/UpdatePackageIndex.cs Switches from BuildTask to MSBuild Task base.
src/Microsoft.DotNet.Build.Tasks.Packaging/src/SplitReferences.cs Switches from BuildTask to MSBuild Task base.
src/Microsoft.DotNet.Build.Tasks.Packaging/src/SplitDependenciesBySupport.cs Switches from BuildTask to MSBuild Task base.
src/Microsoft.DotNet.Build.Tasks.Packaging/src/PromoteDependencies.cs Switches from BuildTask to MSBuild Task base; updates logging importance enum.
src/Microsoft.DotNet.Build.Tasks.Packaging/src/NuGetUtility.cs Replaces internal Log wrapper parameter types with TaskLoggingHelper.
src/Microsoft.DotNet.Build.Tasks.Packaging/src/NuGetPack.cs Switches from BuildTask to MSBuild Task base; updates logging importance enum.
src/Microsoft.DotNet.Build.Tasks.Packaging/src/NuGetAssetResolver.cs Replaces ILog with TaskLoggingHelper; updates logging importance enum.
src/Microsoft.DotNet.Build.Tasks.Packaging/src/Microsoft.DotNet.Build.Tasks.Packaging.csproj Removes source include of Common/Internal/BuildTask.cs.
src/Microsoft.DotNet.Build.Tasks.Packaging/src/HarvestPackage.cs Switches from BuildTask to MSBuild Task base; updates logging importance enum.
src/Microsoft.DotNet.Build.Tasks.Packaging/src/GetSupportedPackagesFromPackageReports.cs Switches from BuildTask to MSBuild Task base.
src/Microsoft.DotNet.Build.Tasks.Packaging/src/GetPackageVersion.cs Switches from BuildTask to MSBuild Task base.
src/Microsoft.DotNet.Build.Tasks.Packaging/src/GetPackageFromModule.cs Switches from BuildTask to MSBuild Task base.
src/Microsoft.DotNet.Build.Tasks.Packaging/src/GetPackageDestination.cs Switches from BuildTask to MSBuild Task base.
src/Microsoft.DotNet.Build.Tasks.Packaging/src/GetPackageDescription.cs Switches from BuildTask to MSBuild Task base.
src/Microsoft.DotNet.Build.Tasks.Packaging/src/GetMinimumNETStandard.cs Switches from BuildTask to MSBuild Task base.
src/Microsoft.DotNet.Build.Tasks.Packaging/src/GetLayoutFiles.cs Switches from BuildTask to MSBuild Task base; updates logging importance enum.
src/Microsoft.DotNet.Build.Tasks.Packaging/src/GetLastStablePackage.cs Switches from BuildTask to MSBuild Task base.
src/Microsoft.DotNet.Build.Tasks.Packaging/src/GetInboxFrameworks.cs Switches from BuildTask to MSBuild Task base; updates logging importance enum.
src/Microsoft.DotNet.Build.Tasks.Packaging/src/GetAssemblyReferences.cs Switches from BuildTask to MSBuild Task base.
src/Microsoft.DotNet.Build.Tasks.Packaging/src/GetApplicableAssetsFromPackages.cs Switches from BuildTask to MSBuild Task base.
src/Microsoft.DotNet.Build.Tasks.Packaging/src/GetApplicableAssetsFromPackageReports.cs Switches from BuildTask to MSBuild Task base.
src/Microsoft.DotNet.Build.Tasks.Packaging/src/GenerateRuntimeDependencies.cs Switches from BuildTask to MSBuild Task base; updates logging importance enum.
src/Microsoft.DotNet.Build.Tasks.Packaging/src/GeneratePackageReport.cs Switches from BuildTask to MSBuild Task base.
src/Microsoft.DotNet.Build.Tasks.Packaging/src/FilterUnknownPackages.cs Switches from BuildTask to MSBuild Task base.
src/Microsoft.DotNet.Build.Tasks.Packaging/src/CreateTrimDependencyGroups.cs Switches from BuildTask to MSBuild Task base.
src/Microsoft.DotNet.Build.Tasks.Packaging/src/ApplyPreReleaseSuffix.cs Switches from BuildTask to MSBuild Task base.
src/Microsoft.DotNet.Build.Tasks.Packaging/src/ApplyMetaPackages.cs Switches from BuildTask to MSBuild Task base.
src/Microsoft.DotNet.Build.Tasks.Packaging/src/ApplyBaseLine.cs Switches from BuildTask to MSBuild Task base.
src/Microsoft.DotNet.Build.Tasks.Installers/src/StabilizeWixFileId.cs Switches from BuildTask to MSBuild Task base.
src/Microsoft.DotNet.Build.Tasks.Installers/src/GenerateMsiVersion.cs Switches from BuildTask to MSBuild Task base.
src/Microsoft.DotNet.Build.Tasks.Installers/src/GenerateMacOSDistributionFile.cs Switches from BuildTask to MSBuild Task base.
src/Microsoft.DotNet.Build.Tasks.Installers/src/GenerateGuidFromName.cs Switches from BuildTask to MSBuild Task base.
src/Microsoft.DotNet.Build.Tasks.Installers/src/GenerateCurrentVersion.cs Switches from BuildTask to MSBuild Task base.
src/Microsoft.DotNet.Build.Tasks.Installers/src/ExecWithRetries.cs Switches from BuildTask to MSBuild Task base; resolves Task.Delay naming collision.
src/Microsoft.DotNet.Build.Tasks.Installers/src/CreateWixCommandPackageDropBase.cs Switches from BuildTask to MSBuild Task base; updates logging importance enum.
src/Microsoft.DotNet.Build.Tasks.Installers/src/CreateRpmPackage.cs Switches from BuildTask to MSBuild Task base.
src/Microsoft.DotNet.Build.Tasks.Installers/src/CreateMD5SumsFile.cs Switches from BuildTask to MSBuild Task base.
src/Microsoft.DotNet.Build.Tasks.Installers/src/CreateDebPackage.cs Switches from BuildTask to MSBuild Task base.
src/Microsoft.DotNet.Build.Tasks.Installers/src/CreateControlFile.cs Switches from BuildTask to MSBuild Task base.
src/Microsoft.DotNet.Build.Tasks.Installers/src/CreateChangelogFile.cs Switches from BuildTask to MSBuild Task base.
src/Microsoft.DotNet.Build.Tasks.Installers/Microsoft.DotNet.Build.Tasks.Installers.csproj Removes source include of Common/Internal/BuildTask.cs.
src/Microsoft.DotNet.Build.Tasks.FileCatalog/GenerateFileCatalog.cs Removes BuildTask alias; task now derives from Microsoft.Build.Utilities.Task.
src/Common/Internal/BuildTask.cs Deletes custom BuildTask/ILog/LogImportance implementation.

Review details

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 74/74 changed files
  • Comments generated: 4
  • Review effort level: Lite

- Remove the `using Microsoft.Build.Utilities;` directives that were not
  needed, since the base type is spelled out as
  `Microsoft.Build.Utilities.Task` to avoid colliding with
  `System.Threading.Tasks.Task`. The using is kept only where
  `TaskLoggingHelper` is named.
- Fix a pre-existing typo in a ValidateHarvestVersionIsLatestForRelease
  log message ("package erreleasea." -> "package release.").

Co-authored-by: Copilot <[email protected]>
Copilot-Session: be19d794-fe4f-43fe-9e6e-f6e6b13ec6e7
Copilot AI review requested due to automatic review settings August 27, 2026 16:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review details

  • Files reviewed: 74/74 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Sweep of every file in this PR for using directives that no longer
resolve to anything:

- `using Microsoft.DotNet.Build.Tasks;` in four files. Deleting
  BuildTask.cs left that namespace with no types at all, so these only
  still compiled because sub-namespaces keep the name resolvable.
- `using Microsoft.Build.Utilities;` in eleven files. These were already
  unused before this change; the base type is spelled out as
  `Microsoft.Build.Utilities.Task`, so nothing brings them back into use.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: be19d794-fe4f-43fe-9e6e-f6e6b13ec6e7
Copilot AI review requested due to automatic review settings August 27, 2026 16:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review details

  • Files reviewed: 74/74 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Import Microsoft.Build.Utilities and derive from `Task` directly, rather
than spelling out `Microsoft.Build.Utilities.Task`. Four files keep the
fully qualified form because they also import System.Threading.Tasks:

- Microsoft.DotNet.Build.Tasks.Installers/src/ExecWithRetries.cs
- Microsoft.DotNet.Build.Tasks.Packaging/src/GetLastStablePackage.cs
- Microsoft.DotNet.Build.Tasks.Packaging/src/UpdatePackageIndex.cs
- Microsoft.DotNet.Build.Tasks.Packaging/src/ValidateHarvestVersionIsLatestForRelease.cs

Since ExecWithRetries keeps the qualified base type, its Task.Delay call
no longer needs qualifying either.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: be19d794-fe4f-43fe-9e6e-f6e6b13ec6e7
Copilot AI review requested due to automatic review settings August 27, 2026 16:22
@ViktorHofer
ViktorHofer enabled auto-merge (squash) August 27, 2026 16:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review details

  • Files reviewed: 74/74 changed files
  • Comments generated: 2
  • Review effort level: Lite

@ViktorHofer
ViktorHofer merged commit e055178 into dotnet:main Aug 28, 2026
12 checks passed
ViktorHofer added a commit to ViktorHofer/arcade that referenced this pull request Aug 28, 2026
Resolves conflicts with the four extracted PRs that have since merged:
dotnet#17412 (console output to build log), dotnet#17426 (unused build tasks),
dotnet#17427 (BuildTask base class) and dotnet#17428 (static task state).

Conflict resolution:
- Base classes take main's spelling. Main derives tasks from the short
  `Task` with Microsoft.Build.Utilities imported, except in the four
  files that also import System.Threading.Tasks and therefore keep the
  fully qualified name. The multithreading attribute and
  IMultiThreadableTask from this branch are layered on top.
- The three tasks deleted as dead on main stay deleted, dropping their
  annotations with them.
- GenAPITask.LogTextWriter and several using blocks were duplicated by
  the automatic merge; kept main's copy in each case. Main's LogTextWriter
  logs from a dedicated LogPendingLine rather than overriding Flush, so
  an explicit Flush() no longer emits a partial line.
- Kept main's wording for the GetPackageDescription cache comment and its
  fix for the "erreleasea" typo.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: be19d794-fe4f-43fe-9e6e-f6e6b13ec6e7
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Aug 29, 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.

3 participants