Skip to content

Make analyzers and ILLink trimming opt-in via MSBuild properties - #123292

Merged
agocke merged 20 commits into
mainfrom
copilot/update-build-configuration-analyzers
Sep 17, 2026
Merged

agocke merged 20 commits into
mainfrom
copilot/update-build-configuration-analyzers

Conversation

Copilot AI commented Jan 16, 2026 •

Copy link
Copy Markdown
Contributor

Description

Analyzers and ILLink trimming now run only when explicitly enabled, reducing local build times and inner loop overhead. Comprehensive jobs in the global-build pipeline ensure code quality checks run on every PR.

Changes

  • MSBuild properties: Added RunAnalyzersInBuild and RunILLinkInBuild properties (default: disabled)

    • eng/Analyzers.targets: Defaults RunAnalyzers=false unless RunAnalyzersInBuild=true
    • src/libraries/Directory.Build.targets: Requires RunILLinkInBuild=true for trimming in NetCoreApp source projects
    • Project-level overrides via RunAnalyzers or ILLinkTrimAssembly still respected
  • CI pipeline: Integrated into eng/pipelines/global-build.yml

    • Runs on all PRs to main and release branches with path-based filtering
    • Libraries_AnalyzersLinker job with -restore -build -pack plus analyzer/linker checks covering platforms: linux_x64_dev_innerloop, windows_x64, osx_arm64
    • CoreClr_Tools_AnalyzersLinker job for CoreLib and tools with analyzer/linker checks on linux_x64_dev_innerloop
    • Jobs positioned logically after RuntimeFlavor_Mono and before Musl_Validation to maintain clean git history
    • Removed redundant Libraries_WithPackages job (superseded by new analyzer/linker jobs)
    • Job names avoid conflicts with existing AllConfigurations jobs in other pipelines
  • Documentation: Added build examples in docs/workflow/building/libraries/README.md

Usage

# Enable analyzers only
./build.sh libs -c Release /p:RunAnalyzersInBuild=true

# Enable trimming only
./build.sh libs -c Release /p:RunILLinkInBuild=true

# Enable both
./build.sh libs -c Release /p:RunAnalyzersInBuild=true /p:RunILLinkInBuild=true
Original prompt

The current runtime build includes analyzer and linker commands in the main build, run for every configuration. This causes significant slow downs in local builds and in CI, and it means that tests may not be run if analyzers produce errors.

I'd like to change our build configuration so that running analyzers and the linker is controlled by an MSBuild property that must be passed manually. Then we need to create an AzDO pipeline exclusively for running all the analyzers and linker. Can you help implement this? Work incrementally, in small commits.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Update build configuration for analyzer and linker control Make analyzers and ILLink trimming opt-in via MSBuild properties Jan 16, 2026
Copilot AI requested a review from agocke January 16, 2026 22:02
@agocke

agocke commented Jan 17, 2026

Copy link
Copy Markdown
Member

@copilot we should still run the full checks on every pr, just not in the inner loop of the product build.

Copilot AI commented Jan 17, 2026

Copy link
Copy Markdown
Contributor Author

@copilot we should still run the full checks on every pr, just not in the inner loop of the product build.

Updated in ed5458b. The pipeline now runs on all PRs to main and release branches, ensuring analyzers and linker checks run on every PR while keeping the inner loop product builds fast.

@jkoritzinsky

Copy link
Copy Markdown
Member

We should also have a leg that triggers the "all configurations build" for libraries. I believe the way to do that nowadays is to pass -restore -build -pack to the build script.

@jkoritzinsky

Copy link
Copy Markdown
Member

Also, maybe we want to add this into the global-build.yml pipeline? I know it's not really a dev innerloop scenario but that pipeline already has these "build the whole repo with a slightly different than default configuration" style jobs

@agocke

agocke commented Jan 23, 2026

Copy link
Copy Markdown
Member

@copilot please move this job into the global-build pipeline

Copilot AI commented Jan 23, 2026 •

Copy link
Copy Markdown
Contributor Author

We should also have a leg that triggers the "all configurations build" for libraries. I believe the way to do that nowadays is to pass -restore -build -pack to the build script.

Added in 1970403. Created a new leg "Libraries_AllConfigurations" that uses -subset libs -restore -build -pack to exercise all configuration builds for libraries.

@copilot please move this job into the global-build pipeline

Done in 1970403. Moved all analyzer and linker jobs into global-build.yml and deleted the standalone pipeline.

Copilot AI and others added 7 commits January 22, 2026 22:28
- Add RunAnalyzersInBuild property to control analyzer execution
- Add RunILLinkInBuild property to control ILLink trimming
- Default both to disabled for faster local builds and CI
- Projects can still explicitly override via ILLinkTrimAssembly or RunAnalyzers

Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
- Create runtime-analyzers-linker.yml pipeline for scheduled runs
- Add documentation for RunAnalyzersInBuild and RunILLinkInBuild properties
- Pipeline runs on main branch scheduled at 9:00 and 21:00 UTC

Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
- Changed pr trigger from 'none' to run on main and release branches
- Pipeline now runs on PRs to ensure code quality checks
- Updated documentation to reflect PR runs
- Keeps inner loop builds fast by using opt-in properties

Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
- Move analyzer and linker jobs from standalone pipeline to global-build.yml
- Add "all configurations" library build leg with -restore -build -pack
- Delete runtime-analyzers-linker.yml standalone pipeline
- Update documentation to reference global-build pipeline
- Add path-based conditions for better PR filtering

Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
- Combine all-configurations build with analyzer and linker checks
- Run on linux_x64_dev_innerloop, linux_x64, windows_x64, osx_arm64
- Remove separate platform-specific analyzer jobs and Mono job
- Build args: -subset libs -restore -build -pack with /p:RunAnalyzersInBuild=true /p:RunILLinkInBuild=true
@agocke
agocke force-pushed the copilot/update-build-configuration-analyzers branch from 1970403 to 1ab89f4 Compare January 23, 2026 06:42
Comment thread eng/pipelines/global-build.yml
@stephentoub stephentoub added the area-Tools-ILLink .NET linker development as well as trimming analyzers label Jan 26, 2026
- Libraries_AllConfigurations supersedes Libraries_WithPackages
- AllConfigurations includes -restore -build -pack (more comprehensive than just -pack)
- Runs on multiple platforms including linux_x64_dev_innerloop
- Includes analyzer and linker checks
- Addresses feedback to combine the jobs

Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Draft Pull Request was automatically closed for 30 days of inactivity. Please let us know if you'd like to reopen it.

@github-actions github-actions Bot locked and limited conversation to collaborators Apr 8, 2026
@jkotas
jkotas deleted the copilot/update-build-configuration-analyzers branch May 22, 2026 15:59
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: f1dc4389-ac26-41b4-aec5-7cfc073a6b0e
@agocke agocke reopened this Aug 18, 2026
Copilot AI lite review requested due to automatic review settings August 19, 2026 18:09
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: f1dc4389-ac26-41b4-aec5-7cfc073a6b0e
@agocke
agocke marked this pull request as ready for review August 19, 2026 23:19
@agocke

agocke commented Aug 19, 2026

Copy link
Copy Markdown
Member

This PR appears to be effective. Windows numbers for example:

• Windows x64 CoreCLR: 53.6m → 41.3m (−23%)
• Windows x64 checked libraries: 49.2m → 39.4m (−20%)
• Windows x86 checked libraries: 46.4m → 36.7m (−21%)

@agocke

agocke commented Aug 20, 2026

Copy link
Copy Markdown
Member

@jkoritzinsky for re-review

@jkoritzinsky

Copy link
Copy Markdown
Member

As we have moved build error diagnostics for LibraryImportGenerator and other generators to use analyzers, this means we can easily have CI build breaks when PRs are merged, especially has LibraryImportGenerator does a "good enough" implementation so people can copy the source locally and adjust it.

We need to have at least one build that builds everything in the product (all configurations build) with analyzers enabled in CI to ensure we don't have a bunch of avoidable breaks in main.

@agocke

agocke commented Aug 20, 2026

Copy link
Copy Markdown
Member

Isn't that what the new job is supposed to do?

@jkoritzinsky

Copy link
Copy Markdown
Member

I missed that we still have the all-configurations leg. That combined with the new tools leg helps, but we still don't get validation of CoreLib on all OS builds. I think we need to also have a job (could be part of one of the existing ones) that builds CoreLib for all OSes to make sure we don't have an easy category of breaks that only show up in CI.

Fold CoreLib into the existing Linux, Windows, and macOS analyzer matrix and leave the Linux-only job focused on tools.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@agocke

agocke commented Aug 24, 2026

Copy link
Copy Markdown
Member

Fixed -- the libraries legs now also include the coreclr build so we are getting full OS coverage

@agocke
agocke merged commit a19a30d into main Sep 17, 2026
185 checks passed
@github-project-automation github-project-automation Bot moved this to Done in AppModel Sep 17, 2026
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Sep 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-Tools-ILLink .NET linker development as well as trimming analyzers linkable-framework Issues associated with delivering a linker friendly framework

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants