Repository navigation
Onboard MSBuild task projects to Microsoft.Build.TaskAuthoring.Analyzer (report-only) - #54979
Merged
Merged
Conversation
Adds the Microsoft.Build.TaskAuthoring.Analyzer (the MSBuild thread-safe task analyzer) to the 12 projects that contain MSBuild task implementations, in report-only mode so the repo keeps building green while the multithreaded-task migration is staged across follow-up PRs. Mechanism (centralized + opt-in): - Directory.Packages.props: pin the analyzer (18.9.0-preview-26310-106). - eng/MSBuildTaskAuthoringAnalyzer.props (new): adds the analyzer as an analyzers-only PackageReference for projects that set IsMSBuildTaskProject=true (excluded in source-only builds). Imported from Directory.Build.targets. - 12 task .csproj files opt in via <IsMSBuildTaskProject>true</IsMSBuildTaskProject>. - .editorconfig downgrades MSBuildTask0001-0005 to suggestion (info level), which keeps the build green without any warnings-as-errors exemptions. StaticWebAssetsSdk sets root = true, so its .editorconfig carries its own copy of the block. This surfaces 373 unique findings (MSBuildTask0002/0003/0005) across 11 projects; follow-up PRs can raise severity per diagnostic category or per task class via .editorconfig and migrate those tasks to IMultiThreadableTask / TaskEnvironment. Co-authored-by: Copilot <[email protected]>
Contributor
There was a problem hiding this comment.
Pull request overview
Onboards dotnet/sdk MSBuild task projects to the Microsoft.Build.TaskAuthoring.Analyzer in report-only mode, so task thread-safety findings are surfaced without breaking builds. This lays groundwork for incremental migration to MSBuild’s multithreaded task model (IMultiThreadableTask / TaskEnvironment).
Changes:
- Add a centralized opt-in mechanism (
IsMSBuildTaskProject=true) that injects the analyzer as analyzers-only and skips source-only builds. - Pin the analyzer version via central package management.
- Configure analyzer severities in
.editorconfig(and a duplicated block undersrc/StaticWebAssetsSdkdue toroot = true), and opt 12 task projects into analysis.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/WebSdk/Publish/Tasks/Microsoft.NET.Sdk.Publish.Tasks.csproj | Opts the publish tasks project into the analyzer via IsMSBuildTaskProject. |
| src/TemplateEngine/Tools/Microsoft.TemplateEngine.Authoring.Tasks/Microsoft.TemplateEngine.Authoring.Tasks.csproj | Opts template authoring tasks into the analyzer. |
| src/Tasks/sdk-tasks/sdk-tasks.csproj | Opts sdk-tasks into the analyzer. |
| src/Tasks/Microsoft.NET.Build.Tasks/Microsoft.NET.Build.Tasks.csproj | Opts build tasks into the analyzer. |
| src/Tasks/Microsoft.NET.Build.Extensions.Tasks/Microsoft.NET.Build.Extensions.Tasks.csproj | Opts build extensions tasks into the analyzer. |
| src/StaticWebAssetsSdk/Tasks/Microsoft.NET.Sdk.StaticWebAssets.Tasks.csproj | Opts static web assets tasks into the analyzer. |
| src/StaticWebAssetsSdk/.editorconfig | Adds a local severity override block because this editorconfig is root = true. |
| src/RazorSdk/Tasks/Microsoft.NET.Sdk.Razor.Tasks.csproj | Opts Razor tasks into the analyzer. |
| src/Dotnet.Watch/DotNetWatchTasks/DotNetWatchTasks.csproj | Opts dotnet-watch tasks into the analyzer. |
| src/Containers/Microsoft.NET.Build.Containers/Microsoft.NET.Build.Containers.csproj | Opts container-related tasks into the analyzer. |
| src/Compatibility/GenAPI/Microsoft.DotNet.GenAPI.Task/Microsoft.DotNet.GenAPI.Task.csproj | Opts GenAPI task project into the analyzer. |
| src/Compatibility/ApiCompat/Microsoft.DotNet.ApiCompat.Task/Microsoft.DotNet.ApiCompat.Task.csproj | Opts ApiCompat task project into the analyzer. |
| src/BlazorWasmSdk/Tasks/Microsoft.NET.Sdk.BlazorWebAssembly.Tasks.csproj | Opts Blazor WASM tasks into the analyzer. |
| eng/MSBuildTaskAuthoringAnalyzer.props | Implements the opt-in + analyzers-only PackageReference, excluded for source-only builds. |
| Directory.Packages.props | Pins Microsoft.Build.TaskAuthoring.Analyzer package version centrally. |
| Directory.Build.targets | Imports the opt-in analyzer props for all projects. |
| .editorconfig | Sets repo-wide severities for MSBuildTask0001-0005 (note: currently uses silent, see PR comment). |
baronfel
requested review from
a team
and removed request for
a team,
tmat and
vijayrkn
June 25, 2026 15:03
baronfel
commented
Jun 25, 2026
baronfel
commented
Jun 25, 2026
JanProvaznik
approved these changes
Jun 25, 2026
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
…ncy flow Per review feedback, the analyzer is now wired up as a package dependency in eng/Version.Details.xml so the version produced by the msbuild repo (via dotnet/dotnet) flows to the sdk repo, instead of being hardcoded in Directory.Packages.props. The package already exists at the current Microsoft.Build flow version (18.9.0-preview-26311-113), so no MSBuild dependency bump is needed. Because it now flows through source build, the DotNetBuildSourceOnly guard is removed from the onboarding props. Co-authored-by: Copilot <[email protected]>
Member
Author
|
Wired the analyzer up as a package dependency per the package-dependency-flow guidance:
Full |
Co-authored-by: Copilot <[email protected]>
mthalman
approved these changes
Jun 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Onboards the repo to the
Microsoft.Build.TaskAuthoring.Analyzer(the MSBuild thread-safe task analyzer) and applies it to the 12 projects that contain MSBuild task implementations, in report-only mode. The repo builds green (0 errors, 0 warnings); every analyzer finding surfaces as an info-level suggestion.This is the first step toward getting SDK's MSBuild Tasks 'green' from an analyzer perspective. Follow-up PRs can then tackle one task class — or one diagnostic category — at a time by raising severity in
.editorconfig.Mechanism (centralized + opt-in)
Directory.Packages.props— pins the analyzer (18.9.0-preview-26310-106, dotnet-eng feed).eng/MSBuildTaskAuthoringAnalyzer.props(new) — adds the analyzer as an analyzers-onlyPackageReference(PrivateAssets="all" IncludeAssets="analyzers") for any project that opts in withIsMSBuildTaskProject=true(excluded in source-only builds). Imported fromDirectory.Build.targets..csprojfiles — each opts in via<IsMSBuildTaskProject>true</IsMSBuildTaskProject>..editorconfig— downgradesMSBuildTask0001–0005tosuggestion. At info severity the diagnostics are never promoted to warnings/errors — not even by the MSBuild engine's warn-as-error (MSBuildTreatWarningsAsErrors) that Arcade enables — so noWarningsNotAsErrorsexemption lists are needed.src/StaticWebAssetsSdk/.editorconfig— carries its own copy of thesuggestionblock because it setsroot = trueand so does not inherit the repo-root.editorconfig. It's the only one of the 12 task projects with aroot = trueeditorconfig.Diagnostics
The analyzer raises 373 unique findings across 11 projects (
Microsoft.DotNet.GenAPI.Taskis clean):MSBuildTask0002TaskEnvironmentalternative (env vars, CWD,Path.GetFullPath,Process.Start)MSBuildTask0003MSBuildTask0005Top projects: StaticWebAssets.Tasks (144), sdk-tasks (86), Publish.Tasks (51), Build.Tasks (43).
A full report (per-rule / per-project / per-file breakdown) is attached to the tracking work.
Re-enablement path (follow-up PRs)
dotnet_diagnostic.MSBuildTask000X.severitytowarning/errorin the root.editorconfig(and the StaticWebAssets copy) once that rule is repo-wide clean..editorconfigin that task's source directory raising severity, then migrate that class toIMultiThreadableTask/TaskEnvironment.Validation
build.cmd→ Build succeeded, 0 errors, 0 warnings. No.xlfchanges; no new NETSDK error codes.