Skip to content

Ship TaskAnalyzer as a separate package with safe defaults - #15045

Open
VolPlita wants to merge 3 commits into
dotnet:mainfrom
VolPlita:taskanalyzer-shipping-package-fresh
Open

VolPlita wants to merge 3 commits into
dotnet:mainfrom
VolPlita:taskanalyzer-shipping-package-fresh

Conversation

@VolPlita

@VolPlita VolPlita commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

This PR ships the TaskAnalyzer as a separate Microsoft.Build.TaskAuthoring.Analyzer package and declares the dependency from Microsoft.Build.Framework for build-time analyzer consumption. This keeps analyzer updates independent from MSBuild API versioning while preserving compatibility for older hosts.

Scope:

  • ship the analyzer as a separate package
  • keep the default task-authoring diagnostics safe and non-breaking for regular tasks
  • require opt-in migration configuration for broader MT-style analysis
  • update package metadata and docs to match the shipped package model

Fixes #15035

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings September 16, 2026 10:35
@VolPlita
VolPlita deployed to copilot-pat-pool September 16, 2026 10:35 — with GitHub Actions Active
@VolPlita
VolPlita deployed to copilot-pat-pool September 16, 2026 10:36 — with GitHub Actions Active

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.

🟡 Changes recommended

Critical package-consumption validation and related documentation and release-tracking updates remain unresolved.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

This PR packages TaskAnalyzer with Microsoft.Build.Framework under analyzers/dotnet/cs and enables its shipping configuration.

Changes:

  • Adds the analyzer to the Framework package.
  • Enables shipping configuration.
  • Updates TaskAnalyzer delivery documentation.
File summaries
File Review result
src/TaskAnalyzer/TaskAnalyzer.csproj Enables shipping configuration. Nit (2 votes): release tracking still marks all rules unshipped.
src/TaskAnalyzer/README.md Nit (3 votes): documentation conflicts with the bundled-package model and should distinguish direct references.
src/Framework/Microsoft.Build.Framework.csproj Critical (3 votes): lacks package-consumption validation. Nit (1 vote): the Framework package README does not document the bundled analyzer.
Review details

Suppressed comments (2)

src/Framework/Microsoft.Build.Framework.csproj:105

  • The package README is src/Framework/README.md (Directory.Build.targets sets PackageReadmeFile to README.md), but this change only updates TaskAnalyzer/README.md. A consumer installing Microsoft.Build.Framework therefore gets no documentation of the analyzer, its default MT-only scope, migration option, suppression, or warnings-as-errors behavior. Add this guidance to the Framework package README or link to packaged documentation.
    <!-- Ship the TaskAnalyzer alongside the framework package so consumers receive it without a direct analyzer package reference. -->
    <None Include="$(ArtifactsBinDir)TaskAnalyzer\$(Configuration)\netstandard2.0\Microsoft.Build.TaskAuthoring.Analyzer.dll"
          Pack="true"
          PackagePath="analyzers\dotnet\cs\Microsoft.Build.TaskAuthoring.Analyzer.dll" />

src/Framework/Microsoft.Build.Framework.csproj:105

  • Placing this DLL under analyzers/dotnet/cs makes every existing Microsoft.Build.Framework PackageReference activate diagnostics automatically. The analyzer has warning rules that apply to regular tasks (MSBuildTask0004 and transitive MSBuildTask0005), while the WarningsNotAsErrors exception exists only in the in-repo Tasks project; existing consumer builds using TreatWarningsAsErrors can therefore start failing on a Framework package update. This needs an explicit opt-out/ChangeWave or another opt-in activation path, plus an opt-out test, before shipping.
    <None Include="$(ArtifactsBinDir)TaskAnalyzer\$(Configuration)\netstandard2.0\Microsoft.Build.TaskAuthoring.Analyzer.dll"
          Pack="true"
          PackagePath="analyzers\dotnet\cs\Microsoft.Build.TaskAuthoring.Analyzer.dll" />
  • Files reviewed: 3/3 changed files
  • Comments generated: 3
  • Review effort level: Lite

Comment on lines +103 to +105
<None Include="$(ArtifactsBinDir)TaskAnalyzer\$(Configuration)\netstandard2.0\Microsoft.Build.TaskAuthoring.Analyzer.dll"
Pack="true"
PackagePath="analyzers\dotnet\cs\Microsoft.Build.TaskAuthoring.Analyzer.dll" />
Comment thread src/TaskAnalyzer/README.md Outdated

A Roslyn analyzer that detects unsafe API usage in MSBuild task implementations. It guides task authors toward thread-safe patterns required for MSBuild's multithreaded task execution mode, where multiple tasks may run concurrently in the same process.

This analyzer ships as part of the `Microsoft.Build.Framework` package, under `analyzers/dotnet/cs`, so consuming projects do not need a direct analyzer package reference. The direct-package examples below remain useful for local validation and partner-repo testing.
<IncludeBuildOutput>false</IncludeBuildOutput>
<!-- Don't ship yet, just make it available to partner repositories. -->
<IsShipping>false</IsShipping>
<IsShipping>true</IsShipping>
@VolPlita
VolPlita deployed to copilot-pat-pool September 16, 2026 11:07 — with GitHub Actions Active
@VolPlita
VolPlita deployed to copilot-pat-pool September 16, 2026 11:07 — with GitHub Actions Active
@VolPlita
VolPlita deployed to copilot-pat-pool September 16, 2026 11:08 — with GitHub Actions Active
@baronfel

Copy link
Copy Markdown
Member

I do not think we want to ship the analyzers directly with Microsoft.Build.Framework - this prevents folks that are using older versions of the MSBuild APIs (i.e. for compatibility with older MSBuild hosts) from using newer versions of the analyzers, which still might find useful issues for them to solve.

VolPlita and others added 2 commits September 16, 2026 16:39
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@VolPlita VolPlita changed the title Ship TaskAnalyzer through Microsoft.Build.Framework Ship TaskAnalyzer as a separate package with safe defaults Sep 18, 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.

Ship the MSBuild task-authoring analyzers through Microsoft.Build.Framework

3 participants