Repository navigation
Conversation
) 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 dotnet#15035 --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…otnet#15146) Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Closing because the vs18.12 backport is not wanted. |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The documentation uses the wrong package release version and includes a broken migration-guide link.
Review effort: Balanced
Findings: 3
Open (3)
What changed in this PR
Ships TaskAnalyzer as an independent, opt-in NuGet package without transitive Framework activation.
Changes:
- Adds analyzer packaging metadata and release documentation.
- Removes the explicit Roslyn analyzer dependency.
- Adds package-contract and activation tests.
| File | Description |
|---|---|
src/TaskAnalyzer/TaskAnalyzer.csproj |
Enables shipping the analyzer package. |
src/TaskAnalyzer/README.md |
Documents package installation and links. |
src/TaskAnalyzer/AnalyzerReleases.Unshipped.md |
Moves rules out of the unshipped manifest. |
src/TaskAnalyzer/AnalyzerReleases.Shipped.md |
Records the initial shipped rules. |
src/TaskAnalyzer.Tests/TaskAnalyzer.Tests.csproj |
Generates repository-path test constants. |
src/TaskAnalyzer.Tests/PackageContractTests.cs |
Tests package contents and analyzer activation. |
src/Framework/README.md |
Documents explicit analyzer installation. |
src/Framework/Microsoft.Build.Framework.csproj |
Adds a private analyzer project reference. |
eng/dependabot/Directory.Packages.props |
Removes the explicit Roslyn analyzer version. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
| @@ -1 +1,20 @@ | |||
| ; No shipped releases yet | |||
| ## Release 18.13.0 | |||
| ```xml | ||
| <ItemGroup> | ||
| <PackageReference Include="Microsoft.Build.TaskAuthoring.Analyzer" Version="1.0.0" | ||
| <PackageReference Include="Microsoft.Build.TaskAuthoring.Analyzer" Version="18.13.0" |
| - [Migration Skill Guide](../../.github/skills/multithreaded-task-migration/SKILL.md) | ||
| - [IMultiThreadableTask Interface](https://github.com/dotnet/msbuild/blob/main/src/Framework/IMultiThreadableTask.cs) | ||
| - [TaskEnvironment Class](https://github.com/dotnet/msbuild/blob/main/src/Framework/TaskEnvironment.cs) | ||
| - [Migration Skill Guide](https://github.com/dotnet/msbuild/blob/main/.github/skills/multithreaded-task-migration/SKILL.md) |
There was a problem hiding this comment.
Test Coverage & Completeness found two concrete gaps: the package-contract test blesses repository-wide versioning instead of the requested independent 0.1.0/SHA-suffixed local contract, and its generated repo-root source disappears from incremental compilations when the generation target is skipped.
Warning
Firewall blocked 4 domains
The following domains were blocked by the firewall during workflow execution:
api.github.life-white.ukcafe.github.life-white.ukgithub.life-white.ukraw.githubusercontent.com
[!TIP]
api.github.com is blocked because GitHub API access uses the built-in GitHub tools by default. Instead of adding api.github.com to network.allowed, use tools.github.mode: gh-proxy for direct pre-authenticated GitHub CLI access without requiring network access to api.github.com:
tools:
github:
mode: gh-proxySee GitHub Tools for more information on gh-proxy mode.
To allow these domains, add them to the network.allowed list in your workflow frontmatter:
network:
allowed:
- defaults
- "api.github.com"
- "cafe.github.com"
- "github.com"
- "raw.githubusercontent.com"See Network Configuration for more information.
Generated by Expert Code Review (on open) for #15176 · copilot · gpt56 · 1.1K AIC · ⌖ 5.58 AIC · ⊞ 24.4K
| </GeneratedText> | ||
| <GeneratedFilePath>$(IntermediateOutputPath)TaskAnalyzerTestsConstants.cs</GeneratedFilePath> | ||
| </PropertyGroup> | ||
| <ItemGroup> |
There was a problem hiding this comment.
This generated source is only added to Compile while the incremental target executes. Concrete repro: build the test project once, modify any .cs test file without changing the project/imports, then build again. TaskAnalyzerTestsConstants.cs is newer than $(MSBuildAllProjects), so this target is skipped; CoreCompile reruns for the changed source, but obj/** is excluded from default compile items and the generated file is absent, producing a missing TaskAnalyzerTestsConstants compile error. Declare the generated path/Compile item at evaluation time and leave only file generation in the target (or otherwise ensure the item is present when the target skips).
|
|
||
| analyzerPackage.NuspecReader.GetIdentity().Version.ShouldBe( | ||
| frameworkPackage.NuspecReader.GetIdentity().Version, | ||
| "TaskAnalyzer should use the repository-wide package version."); |
There was a problem hiding this comment.
The contract assertion verifies the opposite of the requested independent analyzer versioning. With this test, an analyzer package using the repository-wide 18.x Framework version passes, and two local packs from different commits can retain the same package version because nothing asserts a SHA suffix. Please assert the 0.1.0 analyzer version contract and that a local pack's normalized version includes the supplied SourceRevisionId short SHA; Framework equality should not be expected.
| { | ||
| internal static class TaskAnalyzerTestsConstants | ||
| { | ||
| public const string RepoRoot = @"$(RepoRoot)"%3B |
There was a problem hiding this comment.
A valid Unix checkout path containing " breaks this generated source. For example, with RepoRoot=/home/runner/msbuild"review/, the output becomes public const string RepoRoot = @"/home/runner/msbuild"review/";, so TaskAnalyzer.Tests fails to compile before the package-contract test runs. Please C#-escape the injected property (double " inside a verbatim literal), or pass the repository root without source generation.

Summary
Backports #15045 and #15146 to
vs18.12.Microsoft.Build.TaskAuthoring.Analyzeras a separate, opt-in package.Microsoft.Build.Frameworkfrom exposing or activating the analyzer transitively.Microsoft.CodeAnalysis.Analyzers3.11.0 dependency that breaks source-build.Compatibility
This adds a new opt-in package and does not change existing build behavior. No ChangeWave is required.
Validation
.\build.cmd -v quietdotnet test src\TaskAnalyzer.Tests\TaskAnalyzer.Tests.csproj -c Release